简体   繁体   中英

jQuery trigger mouseout event

Is it possible to trigger a mouseout event on a link element using jQuery ?

Ie Something of the sort

$(linkEle).mouseout()

I want this to work on an iPad, which even though does not have any mouse cursor, does actually have the event...

Yes, jquery has a mouseout event handler - http://api.jquery.com/mouseout/

$('some_selector_here').mouseout(function() { 
  // Do some stuff
}

$('some_selector_here').trigger('mouseout');

You might be able to use:

.trigger('mouseleave');

In the form of:

$('#elementToTriggerMouseLeaveOn').trigger('mouseleave');

References:

I don't know about the ipad, but it works as you posted. http://jsfiddle.net/tESUc/

$(linkEle).mouseout();

or

$(linkEle).trigger('mouseout');

or

$(linkEle).trigger($.Event('mouseout'));

Try with tap event

tap - triggered after a tapping an pnscreen element.

http://www.roccles.com/?p=134

$('.link').live('tap',function(event) {
//TODO
});

mouse hover state does not exist on touchscreens

Mouse over/out events do not work as required on ipad. Take a look at touchstart/touchmove and touchend events which are specially for touch devices.

Something like this http://jsfiddle.net/hTYKQ/ Will work in ipad but in this fashion:

  • 1st click to the element triggers the mouseenter function.


  • 2nd click triggers stuff.. if it has stuff... like a link ( http://jsfiddle.net/qxM33/1/ i screwed the <a> href but you get the point.)


  • Click outside the element triggers the mouseleave function.

What this story teaches is: jquery mouse over and mouse out functions work much like click functions in ipad .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM