I have a problem with cars using jQuery:
I can not get it to stop transitioning images at the click of a button.
Follow the code:
$('#slide img:eq(0)').addClass("ativo").show();
var text = $('.ativo').attr("alt");
$("#slide").prepend("<p>" + text + "</p>");
var t = setInterval(slide, 5000);
$('#stop').hover(function(event) {
clearInterval(t);
}, function() {
setInterval(slide, 5000);
});
function slide() {
if ($('.ativo').next().size()) {
$('.ativo').fadeOut(2000).removeClass('ativo').next().fadeIn(2000).addClass('ativo');
} else {
$('.ativo').fadeOut(2000).removeClass('ativo');
$('#slide img:eq(0)').fadeIn(2000).addClass('ativo');
}
var text = $('.ativo').attr('alt');
$('#slide p').hide().html(text).delay(500).fadeIn(2000);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><figureid="slide">
<img src="img/paisagem.jpg" alt="imagem 1">
<img src="img/logo.jpg" alt="Imagem 2">
<img src="img/paisagem.jpg" alt="Imagem 3">
</figure>
<button id='start'>Start</button>
<button id='stop'>Stop</button>