这是我的整个代码。我正在试图做的是让 - 。当DOM准备好时,第一个div显示在页面上,第二个显示在延迟后,然后是第三个,依此类推直到150.使用jquery一个接一个地加载div延迟
与当前代码有关的问题是,整个150 div在短暂延迟后立即加载。
My code
-
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test for dashed div</title>
<style type="text/css">
.dashdiv
{
width: 150px;
height: 50px;
background: #ae2d3e;
float:left;
box-shadow: 10px 10px 6px #d4a7b0;
margin: 5px;
}
</style>
</head>
<body>
<?php
for($i =0; $i < 150; $i++)
{
?>
<div class="dashdiv">
This is a div text
</div>
<?php
}
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('div.dashdiv').each(function()
{
$(this).hide().delay(1000).fadeIn(1850);
});
});
</script>
</body>
</html>
这里是一个小提琴:http:// jsfiddle。net/vDLA7/ – wes
非常好的一点提出+1 :) – swapnesh