10

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.

patricksweeney
  • 3,939
  • 7
  • 41
  • 54
ofer dofer
  • 631
  • 2
  • 11
  • 28

3 Answers3

22

Use .trigger() to trigger an event.

$('#foo').trigger('mouseover');
jmoerdyk
  • 5,544
  • 7
  • 38
  • 49
8

You can call the handler directly

$('abc').mouseover();
Ven
  • 19,015
  • 2
  • 41
  • 61
2

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.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497