0
Why doesn't that work?
Let button = document.querySelector("button"); button .addEventListener("click",(e) => { e.target.style.color = "blue"; });
10 Réponses
+ 2
Show the HTML code too.
+ 2
Actually the variable which you create via let keyword your L character should be in small letters not capital L
let button = document.querySelector("button");
button .addEventListener("click",(e) => {
e.target.style.color = "blue";
});
+ 1
What is button there? Is it a class Or id?
+ 1
it works.
Add in script tag in html or
Wrap in window.onload = function(){
//here
}
Add this in js :
onload =()=>{
let button = document.querySelector("button");
button .addEventListener("click",(e) => {
e.target.style.color = "blue";
});
};
+ 1
Thank you very much it works now
0
<!DOCTYPE html>
<html>
<head>
<title>my first website</title>
</head>
<body>
<h1>html</h1>
<button>click me</button>
</body>
</html>
0
Thanks in advance
0
Thanks
- 2
Here guys
- 2
Hi