I have a loop adding/removing the classes on the .master div:
function loopSlide(){
setTimeout(function(){ $(".master").addClass("one") }, 0);
setTimeout(function(){ $(".master").removeClass("one") }, 2000);
setTimeout(function(){ $(".master").addClass("two") }, 2000);
setTimeout(function(){ $(".master").removeClass("two") }, 4000);
setTimeout(function(){ $(".master").addClass("three") }, 4000);
setTimeout(function(){ $(".master").removeClass("three") }, 6000);
setTimeout(loopSlide, 6000);
}
loopSlide()
.master div {
display: none;
}
.master.one div:nth-child(1) {
display: block;
}
.master.two div:nth-child(2) {
display: block;
}
.master.three div:nth-child(3) {
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="master">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
Now I am looking for a way, how to stop the loop by clicking on one of the divs (1, 2, 3).