Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger mouseover function on an element when not really mouseovered

In jQuery, is it possible for an element to act like it is mouseovered automatically when the page is loading, when it is not really mouseovered? I mean, I won't put my pointer on the desired element for it to do what it would do if I put.

like image 492
ofer dofer Avatar asked Mar 11 '13 23:03

ofer dofer


3 Answers

Use .trigger() to trigger an event.

$('#foo').trigger('mouseover');
like image 142
jmoerdyk Avatar answered Sep 29 '22 14:09

jmoerdyk


You can call the handler directly

$('abc').mouseover();
like image 41
Ven Avatar answered Sep 29 '22 12:09

Ven


Put the desired action in the document.ready function as that is when you actually want the action, not on a mouse-over that doesn't happen.

like image 22
Michael Durrant Avatar answered Sep 29 '22 12:09

Michael Durrant