9

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,673
  • 7
  • 42
  • 53
ofer dofer
  • 621
  • 2
  • 10
  • 27

3 Answers3

21

Use .trigger() to trigger an event.

$('#foo').trigger('mouseover');
jmoerdyk
  • 5,485
  • 7
  • 39
  • 48
8

You can call the handler directly

$('abc').mouseover();
Ven
  • 18,849
  • 2
  • 39
  • 59
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
  • 89,394
  • 88
  • 305
  • 468