Home >Backend Development >PHP Tutorial >javascript - Mouse events become invalid after being separated into js, just stay within the tag
I use js to traverse dl tags and give each dl tag mouse events onmouseover and onmouseout. But it doesn't work. Just add the event to the label and make it credible. My js code should be correct. What's going on? js has been imported. What's wrong? Thank you~
This is HTML
This is js
I use js to traverse dl tags and give each dl tag mouse events onmouseover and onmouseout. But it doesn't work. Just add the event to the label and make it credible. My js code should be correct. What's going on? js has been imported. What's wrong? Thank you~
This is HTML
This is js
This is obvious. You let the function execute first instead of binding the function.
<code>Navinodes[i].onmouseover = function(e){ navishow(e.target); } </code>
As for compatibility, I’ll work on it myself!
There should be an error in the event listening. Try using addEventListener() or attachEvent() (for IE). There is no way to post the code on the mobile phone, and you'd better post the code instead of taking a screenshot.