Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  81] [ 4]  / answers: 1 / hits: 111885  / 15 Years ago, tue, february 9, 2010, 12:00:00

Is there a way to programmatically trigger the onmouseover event in plain JavaScript? or extract the method from the onmouseover event to call it directly?



eg



<div id=bottom-div onmouseover=myFunction('some param specific to bottom-div');>
<div id=top-div onmouseover=????????></div>
</div>


top-div is above bottom-div, so the onmouseover won't get fired in bottom-div. i need a way of calling myFunction('some param specific to bottom-div'); from top-div


More From » dom-events

 Answers
45

You would do it something like this:



document.getElementById('top-div').onmouseover();


However, as mentioned in the comments, it would be worth testing before being considered an issue.


[#97622] Saturday, February 6, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
annalieset

Total Points: 733
Total Questions: 92
Total Answers: 109

Location: Greenland
Member since Fri, Jul 31, 2020
4 Years ago
;