Home  >  Article  >  Web Front-end  >  Example analysis of the stop() method of animate in jquery_jquery

Example analysis of the stop() method of animate in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:17:011262browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn