简体   繁体   English

jQuery悬停动画无法正常工作

[英]jquery hover animations not working properly

I am trying to implement a code for animations related to jQuery. 我正在尝试为与jQuery相关的动画实现代码。 Somehow the animations are not working properly. 动画以某种方式无法正常工作。 Below is the code: 下面是代码:

 $(".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> 

You shoud use mouseenter instead hover: 您应该使用mouseenter而不是悬停:

<script type="text/javascript">
    $(".a").mouseenter(function () {
        $(this).toggleClass("animated slideInUp");
     });              
</script>

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

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