使用JavaScript或jQuery按顺序淡入大量对象
Fade in a large amount of objects sequentially with JavaScript or jQuery?
我正试图让900个点一个接一个地淡出。我当前的代码从一个div生成它们,然后为它们分配一个数字类。
$(document).ready(function(){
function generate() {
var circle = $('.circle');
var container = $('#container');
for (var i = 0; i <= 900; i++) {
circle.clone().attr('class', 'circle ' + i).appendTo(container);
}
}
generate();
});
<style>
#container {
width: 1250px;
margin:0 auto;
max-width:1770px;
height: 670px;
overflow:hidden;
background-color:pink;
position:relative;
}
.circle {
border-radius: 50%;
width: 10px;
height: 10px;
background-color:#8AB5DC;
margin:10px;
float:left;
}
</style>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<div id="container">
<div class="circle">
</div>
</div>
这对你有用吗:
$(document).ready(function () {
function generate() {
var duration = 400;
var delayFactor = 40;
var circle = $('.circle');
var container = $('#container');
for (var i = 0; i <= 900; i++) {
circle.clone().attr('class', 'circle ' + i).appendTo(container).hide();
}
$('.circle').each(function (index) {
$(this).delay(index * delayFactor).fadeIn(duration);
});
}
generate();
});
#container {
width: 1250px;
margin:0 auto;
max-width:1770px;
height: 670px;
overflow:hidden;
background-color:pink;
position:relative;
}
.circle {
border-radius: 50%;
width: 10px;
height: 10px;
background-color:#8AB5DC;
margin:10px;
float:left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="container">
<div class="circle"></div>
</div>
使用duration
和delayFactor
值。希望这能有所帮助。
相关文章:
- Javascript将图像src更改为淡入淡出
- css(或jQuery)悬停时淡入淡出
- 将淡入淡出添加到“我的身体背景滑块”
- 多重潜水淡入淡出打开
- 添加/删除类淡入淡出不起作用
- 带有计数器、缩略图、进度条和淡入淡出效果的简单jQuery幻灯片
- 页面加载跳转jquery淡入
- 使用jquery淡入淡出
- 淡入不带HTML的背景图像
- 淡入淡出脚本不起作用
- 具有淡入淡出效果的全背景图像
- jQuery滑块淡入淡出
- 悬停时淡入背景色
- 粗花呢位置完成后,将对象淡入到不可见状态
- 另一种在PageLoad上使对象的定时淡入效果的方法
- 一次两个对象的 JQuery 淡入淡出循环
- 如何将淡入/淡出方法添加到 JS 音频对象
- 幻灯片更改后淡入对象
- 淡入淡出&从另一个帧集中淡出对象
- 使用JavaScript或jQuery按顺序淡入大量对象