之前我在這裏問過問題:how to make image slider into while loop但找不到正確的答案。單張頁面中的多滑塊
現在我修改了一些代碼。它工作正常。 仍然需要簡化JavaScript和CSS。誰能幫我?。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- jQuery (required) -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<!-- Anything Slider -->
<link rel="stylesheet" href="css/anythingslider.css">
<script src="js/jquery.anythingslider.js"></script>
<!-- Define slider dimensions here -->
<style>
#slider1 { width: 200px; height: 250px; }
#slider2 { width: 200px; height: 250px; }
#slider3 { width: 200px; height: 250px; }
#slider4 { width: 200px; height: 250px; }
#slider5 { width: 200px; height: 250px; }
#slider6 { width: 200px; height: 250px; }
</style>
<!-- AnythingSlider initialization -->
<script>
// DOM Ready
$(function(){
$('#slider1').anythingSlider();
});
$(function(){
$('#slider2').anythingSlider();
});
$(function(){
$('#slider3').anythingSlider();
});
$(function(){
$('#slider4').anythingSlider();
});
$(function(){
$('#slider5').anythingSlider();
});
$(function(){
$('#slider6').anythingSlider();
});
</script>
</head>
<body id="simple">
<?php
for($x=1;$x<=6;$x++){
$Slider="slider".$x;
?>
<div id="<?php echo $Slider;?>">
<li><img src="demos/images/slide-civil-1.jpg" alt=""></li>
<li><img src="demos/images/slide-env-1.jpg" alt=""></li>
<li><img src="demos/images/slide-civil-2.jpg" alt=""></li>
<li><img src="demos/images/slide-env-2.jpg" alt=""></li>
</div>
<?php }?>
<!-- END AnythingSlider -->
</body>
</html>
分別訪問他們,你拿了別人的代碼,發佈了一個新問題,*富*。 –