How can I delay addClass in jQuery? I tried but it doesn't work:
$(document).ready(function(){
$(".box1").delay(600).addClass("animated bounce");
});
Thank you in advance!
How can I delay addClass in jQuery? I tried but it doesn't work:
$(document).ready(function(){
$(".box1").delay(600).addClass("animated bounce");
});
Thank you in advance!
The jQuery delay()
method helps to provide a delay between animation queue. In your case, you need to use setTimeout
method.
$(document).ready(function(){
setTimeout(function(){
$(".box1").addClass("animated bounce");
},600)
});
$(document).ready(function() {
setTimeout(function() {
$(".box1").addClass("animated bounce");
}, 600)
});
.box1,
.box2 {
width: 300px;
height: 200px;
margin-bottom: 100px;
margin-left: 100px;
background-color: #62a6c9;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box1"></div>
<div class="box2"></div>