单击单选按钮时,我想要一个新的滑块图像 但不知何故,它保留了旧选择的图像并与新的选择连接。
<script>
$(document).ready(function() {
$('input:radio').change(function() {
var count = 0;
var image = $('#pg-48-0> .panel-row-style');
if (this.value == 'camping') {
var images={};
images = [ "http://development.tripoutside.com/wp-content/uploads/2017/05/camping.jpg"];
}
else if (this.value == 'road-sports') {
var images={};
images = [ "http://development.tripoutside.com/wp-content/uploads/2017/05/bikes.jpg",
"http://development.tripoutside.com/wp-content/uploads/2017/05/bike2.jpg",
"http://development.tripoutside.com/wp-content/uploads/2017/05/bike3.jpg"];
}
else if (this.value == 'snow-sports') {
}
else if (this.value == 'water-sports') {
}
setInterval(function(){
image.css("background-image","url("+images[count++]+")");
if(count == images.length)
{
count = 0;
}
},5000);
});
});
</script>
以下是指向网站的链接:http://development.tripoutside.com/
答案 0 :(得分:0)
我认为在if子句中使用var语句不会产生你想要的效果。已经在函数内声明了图像。 我的第一次尝试是仅声明图像一次并留下额外的声明。