DEV Community

loading...

Discussion on: JQuery: I have a problem with a changement of class on click

Collapse
aadityataparia profile image
Aaditya Taparia

Use setTimeout instead of setInterval

Collapse
andybullet profile image
AndyBullet Author

In this way?

$(document).ready(function(){
$("#7").click(setTimeout(function(){
$("#7").addClass("bg");
}, 2000));
});

$(document).ready(function(){
$("#8").click(setTimeout(function(){
$("#8").addClass("bg");
}, 2000));
});

Collapse
aadityataparia profile image
Aaditya Taparia

Yep