【问题标题】:hover needs to happen for specific container instead of both悬停需要针对特定​​容器而不是两者都发生
【发布时间】:2014-01-23 19:49:13
【问题描述】:

这是小提琴:http://jsfiddle.net/sarvagnya1/ECj4V/

jQuery 代码:

  $(".container").hover(function(){
    $(".circle-hide").animate({height: '0px'});
    },function(){
   $(".circle-hide").animate({height: '95px'});
  });

有两个主要容器,当我将鼠标悬停在其中一个上时,该功能会作用于两个容器。应该进行哪些更改,以便只有发生悬停的容器才会发生动画效果。

【问题讨论】:

    标签: jquery function hover onhover


    【解决方案1】:

    您必须使用this,并且悬停需要发生在circle-cont 而不是container

      $(".circle-cont").hover(function(){
        $(this).find(".circle-hide").animate({height: '0px'});
        },function(){
        $(this).find(".circle-hide").animate({height: '95px'});
      });
    

    JSFIDDLE DEMO

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 2011-03-14
      • 2011-05-06
      • 1970-01-01
      • 2021-05-16
      • 2015-07-27
      相关资源
      最近更新 更多