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

WBOY
Release: 2016-07-06 13:54:14
Original
867 people have browsed it

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>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!