Simulate a mouse-click in Javascript

javascript

Solution

If you're willing to use jQuery, you can use this simple function to do it:

window.setInterval(function(){
    $("#divToClick").trigger("click");
}, 1000);

That will call it every 1000 milliseconds, or 1 second

For a pure Javascript solution, you should take a look at How to trigger event in Javascript

or, if you're not interested in supporting IE, you can do it the simple way, with an `Event()` constructor, and `event.dispatch()`

Problem

Looking for a Javascript that do a left-mouse click on a image/button identified by ID or CLASS name, wait x seconds and repeat. And able to run in developer tools Console tap, in chrome and firefox. Tried to write it myself, cause i figured it would be a simple code, but after 2 hours of trial and error with no luck, i am starting to run out of options. Hopefully a Javascript pro out there got time to help out a very novice user ;) Thanks

Original source

Related problems