jquery触发器在锚上悬停

前端之家收集整理的这篇文章主要介绍了jquery触发器在锚上悬停前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用jQuery在Web环境中开发.

我想知道为什么

  1. $("#a#trigger").trigger('mouseenter');
  2. $("#a#trigger").trigger('hover');
  3. $("#a#trigger").trigger('mouSEOver');

其中3个都不能激活我拥有的悬停功能.

  1. $(function() {
  2.  
  3.  
  4. $('a#trigger').hover(function(e) {
  5. $('div#pop-up').show();
  6.  
  7. },function() {
  8. $('div#pop-up').hide();
  9. });
  10.  
  11. });
  12.  
  13. });

#触发器是锚的名称,#弹出是我的网络中的div元素.

问题是我想在FullCalendar插件中将鼠标悬停在某些事件上,而这些功能不起作用.
谢谢.

解决方法

你在正确的轨道上,问题是选择器中的额外的#,只是删除第一个哈希:
  1. $("a#trigger").trigger('mouseenter');

请注意,由于ID必须是唯一的,因此不需要指定元素类型,$(‘#trigger’)更有效.

另请注意:

Deprecated in jQuery 1.8,removed in 1.9: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events,and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the "hover" pseudo-event-name with the .hover() method,which accepts one or two functions.

猜你在找的jQuery相关文章