Clear Interval not working in slider i have tried a lot but facing same issue is there any one can tell what is problem here and how i can get this resolved? This is a Image slider in Jquery
<script>
$(document).ready(function() {
var current = 2;
var sl = $(".aa").length;
var interval;
function startSlider() {
interval = setInterval(function() {
$(".slider-wrapper").delay(2000);
$(".slider-wrapper").animate({
'margin-left': '-=910'
}, 2000, function() {
current++;
if (current === sl) {
current = 1;
$(".slider-wrapper").delay(2000).animate({
'margin-left': '0'
}, 2000);
}
})
}, 3000);
}
function stopSlider() {
clearInterval(interval);
}
$(".slider-wrapper").on('mouseenter', stopSlider).on('mouseleave', startSlider);
startSlider();
});
</script>
Aucun commentaire:
Enregistrer un commentaire