문제

I would like to create a mouse event manually on an point, knowing its coordinates. I use this function :

$(document.elementFromPoint(x, y)).mousedown();

The click is used by a function that needs the pageX and pageY properties of the event, but it does not work because the created event doesn't have these properties. Does anybody know why?

Thank you!

도움이 되었습니까?

해결책

Simply create a jQuery event with the required properties an pass it over to the "trigger function":

var event = jQuery.Event("mousedown", {pageX: x, pageY: y});
$(document.elementFromPoint(x, y)).trigger(event);

That should work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top