Delete class after 3 seconds

I would like to put a timeout function to remove these two classes, but I have no idea how to do this. Can someone help me enable a timeout here? Thanks in advance.

.done(function(response) { // Make sure that the formMessages div has the 'success' class. $(formMessages).removeClass('error'); $(formMessages).addClass('success'); // Set the message text. $(formMessages).text('Message sent!'); // Clear the form. $('#name').val(''); $('#email').val(''); $('#message').val(''); //$('#budget').val(''); }) 
+5
source share
2 answers

maybe something like ...

  setTimeout(function(){ $(formMessages).removeClass('error'); //....and whatever else you need to do }, 3000); 
+10
source

Using jquery ...:

 $(formMessages) .delay(3000) // its like settimeout .removeClass('error'); 

Link: http://api.jquery.com/delay/

0
source

Source: https://habr.com/ru/post/1204850/


All Articles