我有四个div
元素,这些元素在父项div
之下。这些div
s充满了PHP文件中的数据。我通过jQuery的.getJSON()
获得了数据。无论如何,我需要fadeIn()
/这些divs在一定的顺序。这是我的。jquery中四个div的淡出/淡入淡出帮助
$("#images #image1").fadeOut(2000); //do this first
$("#images #image2").fadeIn(2000);
$("#images #image2").fadeOut(2000); //then this
$("#images #image3").fadeIn(2000);
$("#images #image3").fadeOut(2000); //then this
$("#images #image4").fadeIn(2000);
$("#images #image4").fadeOut(2000); //then this
$("#images #image1").fadeIn(2000); //then this
这是我的index.php文件,其中包含jQuery和CSS,如果有帮助!
<style type="text/css">
#container {
width:320px;
position:relative;
height:60px;
overflow:hidden;
}
#images {
height:60px;
width:320px;
}
#images #image1 {
float:left;
}
#images #image2 {
float:left;
display:none;
}
#images #image3 {
float:left;
display:none;
}
#images #image4 {
float:left;
display:none;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2 /jquery.js"></script>
<script type="text/javascript" src="https://raw.github.com/malsup/cycle/master/jquery.cycle.all.js"></script>
<script type="text/javascript">
//this function will display images from the database
//path is the name of the image
//images is the directory where the images are stored
$("document").ready(function() {
$.getJSON('slide.php', function (data) {
//alert("Data loaded");
$.each(data, function (i, item) {
$("#images").append('<div class="imageone" id="image1"><img src="images/' + item.path + '" width="80px" height="60px"/>' + '</div>');
});
});
$.getJSON('f_steptwo.php', function (data) {
$.each(data, function (i, item) {
$("#images").append('<div class="imagetwo" id="image2"><img src="images/' + item.path + '" width="80" height="60"/>' + '</div>');
});
});
$.getJSON('f_stepthree.php', function (data) {
$.each(data, function (i, item) {
$("#images").append('<div class="imagethree" id="image3"><img src="images/' + item.path + '" width="80" height="60"/>' + '</div>');
});
});
$.getJSON('f_stepfour.php', function (data) {
$.each(data, function (i, item) {
$("#images").append('<div class="imagefour" id="image4"><img src="images/' + item.path + '" width="80" height="60"/>' + '</div>');
});
$("#images #image1").fadeOut(2000);
$("#images #image2").fadeIn(2000);
$("#images #image2").fadeOut(2000);
$("#images #image3").fadeIn(2000);
$("#images #image3").fadeOut(2000);
$("#images #image4").fadeIn(2000);
$("#images #image4").fadeOut(2000);
$("#images #image1").fadeIn(2000);
});
});
</script>
</head>
<body>
<div id="container">
<div id="images">
</div>
</div>
然后这整个过程需要每三秒左右重复一次。任何将不胜感激。这需要在页面加载时发生。
我很高兴有人表现出这家伙如何使用变量,LMFAO。 – alt