我只写了下面的代码。点击按钮后,3个容器应该开始无限闪烁,但闪烁在一段时间后停止。我还没有弄清楚为什么。任何想法?动画停止后,而
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$("#btn").click(function(){
Do();
})
});
function Do(){
$(".container").fadeOut("slow",function(){
$(this).fadeIn("slow",function(){Do();});
});
}
</script>
<style type="text/css">
.container{
background: yellow;
width: 200px;
height: 50px;
font-size: 20px;
}
</style>
</head>
<body>
<button type="button" id="btn">Push Me</button>
<div id="container" class="container">
Hello
</div>
<div id="container2" class="container">
Hello
</div>
<div id="container3" class="container">
Hello
</div>
</body>
</html>
奇怪的行为确实如此。为那些想玩它的人准备的小提琴。 http://jsfiddle.net/Q9rKc/ –
它引发一个Uncaught RangeError:最大调用堆栈大小超过 –
你可以尝试调用函数Do()与每个.container像这样[http://jsfiddle.net/Q9rKc/2 /](http://jsfiddle.net/Q9rKc/2/) –