javascript jQuery 触发 mouseout 事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6848735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 22:05:46  来源:igfitidea点击:

jQuery trigger mouseout event

javascriptjquerycssipadsafari

提问by testndtv

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

是否可以使用 jQuery 在链接元素上触发 mouseout 事件?

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...

我希望它在 iPad 上工作,即使它没有任何鼠标光标,但实际上确实有事件......

回答by barfoon

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

是的,jquery 有一个 mouseout 事件处理程序 - http://api.jquery.com/mouseout/

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

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

回答by David says reinstate Monica

You might be able to use:

您或许可以使用:

.trigger('mouseleave');

In the form of:

形式如下:

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

References:

参考:

回答by James Montagne

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

我不知道 ipad,但它可以像你发布的那样工作。 http://jsfiddle.net/tESUC/

回答by tskuzzy

$(linkEle).mouseout();

or

或者

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

or

或者

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

回答by Naga Harish M

Try with tap event

尝试点击事件

tap - triggered after a tapping an pnscreen element.

点击 - 在点击 pnscreen 元素后触发。

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

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

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

mouse hover state does not exist on touchscreens

触摸屏上不存在鼠标悬停状态

回答by ShankarSangoli

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.

鼠标悬停/退出事件在 ipad 上无法按要求工作。查看专为触摸设备设计的 touchstart/touchmove 和 touchend 事件。

回答by Joonas

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

像这样的东西http://jsfiddle.net/hTYKQ/将在 ipad 中工作,但以这种方式:

  • 1st click to the element triggers the mouseenterfunction.


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


  • Click outside the element triggers the mouseleavefunction.

  • 第一次单击元素会触发该mouseenter功能。


  • 第二次点击会触发东西..如果它有东西......就像一个链接( http://jsfiddle.net/qxM33/1/我搞砸了,<a>href但你明白了。)


  • 单击元素外部会触发该mouseleave功能。

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

这个故事教导的是:jquery 鼠标悬停和鼠标移出功能的工作方式与ipad 中的点击功能非常相似。