gpt4 book ai didi

javascript - jQuery 图片 slider 问题

转载 作者:行者123 更新时间:2023-11-28 09:37:19 27 4
gpt4 key购买 nike

我想使用 html 和 jquery 制作一个简单的图片幻灯片。我试过下面的代码。它只显示第一张图片,不会自动滑到下一张图片。

我只想让这三个简单的图片永远水平滑动。

<html>
<head>
<script src="jquery.min.js"></script>
<style>
#slideShow{
position:absolute;
height:490px;
width:490px;
background-color:#fff;
margin:10px 0 0 10px;
z-index:100;

-moz-box-shadow:0 0 10px #111;
-webkit-box-shadow:0 0 10px #111;
box-shadow:0 0 10px #111;
}

#slideShow ul{
position:absolute;
top:15px;
right:15px;
bottom:15px;
left:15px;
list-style:none;
overflow:hidden;
}

#slideShow li{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
</style>
</head>
<body>

<div id="slideShow">
<ul>
<li><img src="7.png" /></li>
<li><img src="77.jpg" /></li>
<li><img src="777.jpg" /></li>
</ul>
</div>

<script>
jQuery("#slideShow").slider({
orientation: "horizontal",
range:"min",
min: 1,
max: 4,
value: 1,
slide: function( event, ui ) {

}
});
</script>


</body>
</html>

最佳答案

使用这个

    <div class="yourimg_container">
<img src="http://localhost/app/img/off.png" id="Image1"/>
</div>

/* make an array containing your images path (you can fetch images from database using asp.net/php query)*/

var ss= ["http://localhost/app/img/off.png",
"http://localhost/app/img/on.png",
"http://localhost/app/img/slider.png"];


window.setInterval(function(){
slideshow();
}, 3000);

function slideshow(){
var im=$("#Image1").attr("src");

for(i=0;i<ss.length;i++){

if(ss[i]==im){
if(i==ss.length-1) $('#Image1').attr("src",ss[0]);
else $('#Image1').attr("src",ss[i+1]);
}
}

}

关于javascript - jQuery 图片 slider 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25482471/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com