jquery动态绑定hover没有效果

Posted edllixiaoyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery动态绑定hover没有效果相关的知识,希望对你有一定的参考价值。

在JQuery中,hover()函数本身是对 mouseenter && mouseleave 的封装,然而在原生event中,并没有hover这一事件,所以在传递参数hover时,并不会有任何的效果。

 所以将代码换成这样

$(obj).on("mouseover mouseout",function(event){
 if(event.type == "mouseover"){
  //鼠标悬浮
 }else if(event.type == "mouseout"){
  //鼠标离开
 }
})

  

以上是关于jquery动态绑定hover没有效果的主要内容,如果未能解决你的问题,请参考以下文章