Reputation: 50752
Is it possible to trigger a mouseout event on a link element using jQuery ?
I.e. 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...
Upvotes: 8
Views: 23053
Reputation: 7303
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.
Upvotes: 0
Reputation: 69915
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.
Upvotes: 0
Reputation: 2789
Try with tap event
tap - triggered after a tapping an pnscreen element.
$('.link').live('tap',function(event) {
//TODO
});
mouse hover state does not exist on touchscreens
Upvotes: 0
Reputation: 36476
$(linkEle).mouseout();
or
$(linkEle).trigger('mouseout');
or
$(linkEle).trigger($.Event('mouseout'));
Upvotes: 0
Reputation: 78650
I don't know about the ipad, but it works as you posted. http://jsfiddle.net/tESUc/
Upvotes: 0
Reputation: 253328
You might be able to use:
.trigger('mouseleave');
In the form of:
$('#elementToTriggerMouseLeaveOn').trigger('mouseleave');
References:
Upvotes: 0
Reputation: 28177
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');
Upvotes: 12