Home >Backend Development >PHP Tutorial >javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

WBOY
WBOYOriginal
2016-07-06 13:54:14907browse

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
javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

This is js

javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

Reply content:

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
javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

This is js

javascript - Mouse events become invalid after being separated into js, ​​just stay within the tag

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn