[英]jquery hover animations not working properly
我正在嘗試為與jQuery相關的動畫實現代碼。 動畫以某種方式無法正常工作。 下面是代碼:
$(".a").hover(function() { $(this).toggleClass("animated slideInUp"); });
.block-section { padding: 50px 0; } .footer-links ul { margin: 0; padding: 0; } .footer-links ul li { list-style: none; display: inline-block; } .footer-links ul li a { color: #fff; background: #E57373; height: 45px; width: 45px; text-align: center; border-radius: 50%; line-height: 44px; font-size: 18px; display: block; margin: 15px 15px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.css" rel="stylesheet"> <footer class="block-section"> <div class="container"> <div class="row"> <div class="col-sm-12"> <div class="footer-links text-center"> <ul> <li><a href="#" class="a"><i class="fa fa-facebook"></i></a></li> <li><a href="#" class="a"><i class="fa fa-twitter"></i></a></li> <li><a href="#" class="a"><i class="fa fa-google-plus"></i></a></li> <li><a href="#" class="a"><i class="fa fa-dribbble"></i></a></li> </ul> </div> </div> </div> </div> </footer>
您應該使用mouseenter而不是懸停:
<script type="text/javascript">
$(".a").mouseenter(function () {
$(this).toggleClass("animated slideInUp");
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.