Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
144
rated 0 times [  149] [ 5]  / answers: 1 / hits: 25222  / 12 Years ago, tue, april 24, 2012, 12:00:00

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.


More From » jquery

 Answers
19

This can actually be accomplished with the document.elementFromPoint method. A jQuery example:



function simulateClick(x, y) {
jQuery(document.elementFromPoint(x, y)).click();
}
simulateClick(100, 250);
simulateClick(400, 250);


Edit: Here is a working example: http://jsfiddle.net/z5YjY/


[#86004] Monday, April 23, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jenamackennac

Total Points: 304
Total Questions: 110
Total Answers: 107

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
jenamackennac questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Wed, Apr 21, 21, 00:00, 3 Years ago
Thu, Apr 1, 21, 00:00, 3 Years ago
Tue, Feb 2, 21, 00:00, 3 Years ago
;