jquery 同时绑定hover 和click事件,但只有click事件可以触发?

$('.dropdown').on('click hover', '.dropdown-icon', function() {
        $(this).parent().next('.dropdown-menu').toggle();
    });

只有click事件可以触发,hover不起作用

阅读 6.8k
2 个回答

并不存在hover这个事件
JQuery的hover方法是mouseenter和mouseleave事件的简略写法罢了

Calling $(selector).hover(handlerInOut) is shorthand for:

$( selector ).on( "mouseenter mouseleave", handlerInOut );

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题