Sublime Forum

Eventlistener

#1

Please am having a challenge with how to use event listener, can I get help as to how to go about it?
Thanks

0 Likes

#2

Can you provide more details, such as what event you’re trying to listen for and why? Your question is a little open ended.

That said:

1 Like

#3

Please I want use the evenlistener such that the text and color will change when the mouse is hovered on it, I see codes as per the image below

I used the code

after connecting js. to the html on sublime.

0 Likes

#4

This is the feedback I get on the console using the chrome browser


Cannot read properties of null ( reading ‘addEventListener’).

Your assistance will be much more appreciated please.
Thank you

0 Likes

#5

Oh I see; your question is JavaScript related and not Sublime Text related.

This is a support forum for Sublime and not for general computing problems, so I would recommend that if you have issues like this you ask in a more HTML/JavaScript specific location.

That said, your error is caused by the call to querySelector on line 1 returning null because the HTML page has no tag with a id="one" in it.

0 Likes

#6

Thanks so much am very grateful.

0 Likes