繁体   English   中英

jQuery动画不透明度箭头mouseenter mouseleave

[英]jquery animate opacity arrows mouseenter mouseleave

当我们过去使用箭头导航时,我正在尝试为jquery添加不透明度效果,但似乎什么也没发生:(。您知道我的Jquery脚本出了什么问题。

这是我的Jquery:

$(document).ready(function(){
  $(".flscroll").mouseenter(function(){
    $("flscroll").animate({opacity:1},300);
  });
  $(".flscroll").mouseleave(function(){
    $(".flscroll").animate({opacity:.8},300);
  });
});

我在css中定义了箭头:

.flscroll {
        display:block;
        height: 83px;
        opacity: 0.8;
        position: fixed;
        top: 40%;
        z-index: 1000;
    }
    .ie8 .flscroll {
        filter: alpha(opacity=80);
    }
    #flscrollg {
        background: url(images/sprite.png) no-repeat 50px -100px;
        left: -30px;
        padding-left: 50px;
        width: 52px;
    }
    #flscrolld {
        background: url(images/sprite.png) no-repeat left -200px;
        padding-right: 50px;
        right: -30px;
        width: 53px;
    }

我的html箭头声明是这样的:

<a href="#1" title="previous" class="flscroll" id="flscrollg">&nbsp;</a>
<a href="#1" title="next" class="flscroll" id="flscrolld">&nbsp;</a>

所以我在评论中提到,这可能是您的Jquery在此行代码中缺少句点

$("flscroll").animate({opacity:1},300);
//Should be
$(".flscroll").animate({opacity:1},300);

我已经在此FIDDLE中添加了它,并且效果很好。

这是你所追求的吗?

尝试这个

$(document).ready(function(){
  $(".flscroll").on('mouseenter',function(){
    $(this).animate({opacity:1},300);
  }).on('mouseleave',function(){
    $(this).animate({opacity:0.8},300);
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM