Ask coding questions

← Back to all posts
Error
WilliamXing (45)

What's wrong with this repl? I want it to log Click!, then when I click, it prints the coordinates of my click, but it isn't working.

Answered by 19wintersp (1120) [earned 5 cycles]
View Answer
Comments
hotnewtop
19wintersp (1120)

It does work. Are you trying to make it work for the whole page? Currently, it will only log if you click the <h1>.

WilliamXing (45)

Yes, I am trying to make it for the whole page @19wintersp

19wintersp (1120)

@WilliamXing When you are adding the event handler on line 14, you're targeting "h1": the header. If you want it for the whole document, use "body". You may also need to set the height of :root and body to 100% in CSS, so that it takes up the whole of the visible area in the browser window.