How can I simulate a click at x/y co-ordinates using javascript or jquery?
I will use the script multiple times and I want the script to click on postion one then postion two then three then four and so one.
It is better without moving the mouse cursor, but if it has to move then that is fine as well.
This can actually be accomplished with the
document.elementFromPoint
method. A jQuery example:Edit: Here is a working example: http://jsfiddle.net/z5YjY/
On a second take, I'd share my experiences, and update Prestaul's answer.
In most cases, you don't just want to click on an element to induce the 'onclick' event, but you would like to use the click info for something (eg.: move a slider there, or put a popup at that exact place).
I'm mostly using vanilla js, but it blends well with $.
Basically this will pass down the correct pageX / pageY through the event, for further use.
I have updated the fiddle as well, to show a use of these coords: http://jsfiddle.net/V4CdC/