Is there any way to add a class on click and then remove it after 2 or 3 seconds? Thanks in advance
Try this:
$("#your_click_element_id").on('click', function()
{
$(this).addClass("class_name");//or $("#id_of_whatever_you_want)
setTimeout(function() {
$(this).removeClass('class_name');
}, 2000);
});
setTimout
will wait for 2000 ms and then execute the .removeClass()
.
<style>
.class_name{
...
}
</style>