Home > Article > Web Front-end > Example analysis of the stop() method of animate in jquery_jquery
This article uses an example to analyze the function of the stop() method of animate in jquery. Share it with everyone for your reference. The specific analysis is as follows:
Here is a code snippet from a video to tell you the function of stop():
The code is as follows:
<style type="text/css"> ul li{ width:50px; height:30px; background:#333; margin-bottom:10px; color:#fff;} </style> <ul id="flyul"> <li>wod a </li> <li>wod a </li> <li>wod a </li> <li>wod a </li> <li>wod a </li> </ul> <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $('#flyul li').mouseenter(function(){ $(this).stop().animate({ //将此处改为$(this).animate({对比一下不带stop的运行效果 width:'300px' },1000); }); $('#flyul li').mouseleave(function(){ $(this).stop().animate({ //将此处改为$(this).animate({对比一下不带stop的运行效果 width:'50px' },1000); }); </script>
I hope this article will be helpful to everyone’s jQuery programming.