To remove class after delay in jQuery you can use one of the snippet below.
Samples
jQuery Sample using setTimeout()
1 2 3 4 5 |
var element = $('#element'); element.addClass('current'); setTimeout(function() { element.removeClass('current'); }, 2500); |
Samples
jQuery Sample using delay() and queue()
1 2 3 4 |
$("#element").addClass("testclass").delay(2500).queue(function(next){ $(this).removeClass("testclass"); next(); }); |
If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.
Related links:
RT @CodeSnippetsNET: https://t.co/k0FBupAVe6 | Remove class after delay in #jQuery #js #javascript #css #php #html5 #html #webdev
RT @CodeSnippetsNET: https://t.co/k0FBupAVe6 | Remove class after delay in #jQuery #js #javascript #css #php #html5 #html #webdev
RT @CodeSnippetsNET: https://t.co/k0FBupAVe6 | Remove class after delay in #jQuery #js #javascript #css #php #html5 #html #webdev
RT @CodeSnippetsNET: https://t.co/k0FBupAVe6 | Remove class after delay in #jQuery #js #javascript #css #php #html5 #html #webdev