Hypnoz
Hypnoz

Reputation: 1136

How to invoke mousemove with Javascript or jQuery code

I know if you move mouse, that event will invoke however how can I invoke that event just with help of the code?

Upvotes: 2

Views: 268

Answers (3)

john
john

Reputation: 295

Trigger event in jQuery can help you so much

Upvotes: 1

norbitheeviljester
norbitheeviljester

Reputation: 962

If you have a jQuery element from which you want to fire an event you need the trigger method

var $t = jQuery('#idToElement');
$t.trigger('mousemove',['parameter1','parameter2']);

If you want to do this with pure javascript you need the createEvent function of the document object. You can find more about that here

Upvotes: 1

Roko C. Buljan
Roko C. Buljan

Reputation: 206669

AFAIK you cannot move the user's mouse pointer if that was the question.
It would be called "mousejacking" ;)

Not sure why you ask, but,
if your goal is to simulate a click on another element you could do:

$('#element_1').click(function(){
    $('#element_2').click();
});

Upvotes: 1

Related Questions