jQuery .mousemove() event

Syntax and Description


.mousemove(handler)            
.mousemove()

handler is a function to execute each time the event is triggered. Return value is the jQuery object, for chaining purposes.

mousemove binds an event handler to the mousemove event, or trigger that event on an element.

.mousemove(handler) is a shortcut for .bind('mousemove', handler). .mousemove() is a shortcut for .trigger('mousemove').

For example:


<div id="target">Move here</div>
<div id="other">Other</div>

The event handler can be bound to the target:


$('#target').mousemove(function(event) {
   $.print(event.pageX + ', ' + event.pageY);
});

We can also trigger the event when the second button is clicked.


$('#other').click(function() {
//from   ww w  .  j a  v a 2s .  c  om
 $('#target').mousemove();

});




















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities