0

Why doesn't that work?

Let button = document.querySelector("button"); button .addEventListener("click",(e) => { e.target.style.color = "blue"; });

14th Mar 2022, 3:54 PM
Florian Renery
10 ответов
+ 2
Show the HTML code too.
14th Mar 2022, 3:57 PM
Adil
Adil - avatar
+ 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"; });
14th Mar 2022, 4:15 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
What is button there? Is it a class Or id?
14th Mar 2022, 3:56 PM
Jayakrishna 🇮🇳
+ 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"; }); };
14th Mar 2022, 4:17 PM
Jayakrishna 🇮🇳
+ 1
Thank you very much it works now
14th Mar 2022, 4:42 PM
Florian Renery
0
<!DOCTYPE html> <html> <head> <title>my first website</title> </head> <body> <h1>html</h1> <button>click me</button> </body> </html>
14th Mar 2022, 4:09 PM
Florian Renery
0
Thanks in advance
14th Mar 2022, 4:09 PM
Florian Renery
0
Thanks
16th Mar 2022, 5:09 AM
Favour Ndubuisi Okafor
Favour Ndubuisi Okafor - avatar
- 2
Here guys
14th Mar 2022, 4:09 PM
Florian Renery
- 2
Hi
16th Mar 2022, 5:09 AM
Favour Ndubuisi Okafor
Favour Ndubuisi Okafor - avatar