New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Why does this (event handler) doesn't work? [Solved ✅]
Why does this (the event handler) doesn't work? According to w3school, they said, "In HTML event handlers, this refers to the HTML element that received the event," but when I used them, they don't work. In Khan Academy, it worked, but in solo-learn, it didn't. Here's the code if you want the whole thing: https://code.sololearn.com/Wr73mxlcVY7D/#html
5 Answers
+ 2
Thank you! .■. for answering, but I found my answer on the comments on the project.
Ipang commented, "'this' in function refers to 'window' object, use 'event.target' in place of 'this'
Thank you Ipang for the answer!
Problem Solved! ✅
+ 5
Check your css part
.eyes {
background-color: black;
}
You can change background color of eye
+ 4
Try this is js part
function why() {
document.body.style.backgroundColor= "red";
}
0
Well... I wanted to use the js this keyword and I wanted to change the backgroundColor of the circle but still... Thank You :D
0
Thank you :D But I wanted to change the color using javascript and I wanted to use this keyword to change it... but this keyword doesn't work :'(