用户登录
用户注册

分享至

关于jQuery中对hover事件unbind

  • 作者: 功夫不好别来找操
  • 来源: 51数据库
  • 2021-08-01

今天遇到了这个问题,最开始以为直接unbind(“hover”)就可以搞定,失败。网上搜了好多都不是很正确,最后还是在一个老外的博客上看到了正确的方法,现在拿出来共享,原文地址http://harrybailey.com/2008/11/jquery-hover-and-unbinding/

网上所说的取消hover事件有以下几种方式:

/* 这种方式是错误的 */
$(#hover_p).unbind(hover);

/* 这种方式也是错误的 */
$(#hover_p).unbind(mouseover).unbind(mouseout);

/* 这种方式是新增的,在老的版本里是无法使用的 */
$(#hover_p).unbind(mouseenter mouseleave);

/* 正确的,新老版本都可用 */
$(#hover_p).unbind(mouseenter).unbind(mouseleave);

软件
前端设计
程序设计
Java相关