Need some help with JavaScript! I have a slide and I want to add a button to either make it autoplay or stop it. When I just use an Alert inside the function, it works, but when I add the interval code, it won't. Check out my codepen link
Here is the code for my slide:
<div class="Dash_map_wrapSlider" id="Dash_map_wrapSlider">
[slide HTML code here]
</div>
[additional slide HTML code here]
<div class="Dash_map_wrapSliderchoise">
<label for="Dash_map_sumSlideSite">Site / Alarme</label>
<label for="Dash_map_sumSlideAlarme">Technicien / Action</label>
<span id="autoplay" style="color:#fff;">Autoplay</span>
</div>
My JS code :
function playSlide() {
console.log('heeey');
var elementSlide = document.getElementById('autoplay');
elementSlide.onclick = function(){
//alert('hey beauty !');
setInterval(function(){
$('#autoplay');
}, 3000);
};
}
Thank you!