Why my mouseout event listener not working? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Why my mouseout event listener not working?

Can anyone help me understand why my mouse out even listener not working? The mouse out event listener is working well I'm using vs code on my laptop, it also not working on sololearn https://code.sololearn.com/WAr0J4W4072U/?ref=app

1st Mar 2023, 9:27 AM
BaaziM Ali
BaaziM Ali - avatar
5 Respostas
+ 3
myDiv.addEventListener('mouseout', doSomethingElse ) // remove () , spell check lightgreen
1st Mar 2023, 9:51 AM
Jayakrishna šŸ‡®šŸ‡³
+ 3
Jayakrishna šŸ‡®šŸ‡³ The way OP code setting onmouseover event listening parameters is right, but your have given a wrong answer. However BaaziM Ali you have the wrong way to set onmouseout, addEventListener parameter is a callback function pointer. doSomething() means immediately execute the function, which should not set as addEventListenr function parameter. so the correct way is myDiv.addEventListener('mouseover', doSomething); myDiv.addEventListener('mouseout', doSomethingElse);
1st Mar 2023, 12:30 PM
CalviÕ²
CalviÕ² - avatar
+ 1
Jayakrishna šŸ‡®šŸ‡³ & CalviÕ² Thank you guys I firstly didn't give the brakets but but the problem was misspelling the lightgreen word Now it's working
2nd Mar 2023, 3:16 PM
BaaziM Ali
BaaziM Ali - avatar
+ 1
BaaziM Ali you're welcome.. Also i have to thank @ODLNT and @Calvin for noticing mistake.. credit..
2nd Mar 2023, 3:41 PM
Jayakrishna šŸ‡®šŸ‡³
0
CalviÕ² Yes. Thanks for letting me know. I did not checked it before. And i already corrected it, while you may typing then. still, may not complete answer, then add your corrections.. Sry for OP, if i confused any...
1st Mar 2023, 12:36 PM
Jayakrishna šŸ‡®šŸ‡³