2

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

3
  • 1
    JavaScript's document.createEvent (example with mouse event included) and jQuery's trigger Commented Sep 5, 2012 at 19:34
  • As Rob says to fake the event, but as Roko says - it will not actually move the cursor, that is not available in browsers. Commented Sep 5, 2012 at 19:37
  • stackoverflow.com/questions/906486/… This should probably help you, it has been asked before. Commented Sep 5, 2012 at 19:41

3 Answers 3

1

Trigger event in jQuery can help you so much

Sign up to request clarification or add additional context in comments.

Comments

1

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();
});

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.