Slider based on buttons on wp site

I want a new slider images when the radio button are clicked
but somehow it keeps images from old selection and concatenate with the new ones.

<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>

here is the link to site: http://development.tripoutside.com/

Read more here: Slider based on buttons on wp site

Leave a Reply

Your email address will not be published. Required fields are marked *