Event simulation in JavaScript

154 Views Asked by At

How can I simulate events like click, mousedown, mouseout and etc. in JavaScript or jQuery?

2

There are 2 best solutions below

0
Matthijs On BEST ANSWER

Use the trigger method

$(element).trigger('click');

More information: http://api.jquery.com/trigger/

1
Aashray On

Events can be attached to each element in a HTML page. Check out the following link to understand events better.

http://www.w3schools.com/js/js_htmldom_events.asp