Delaying a Javascript code snipped for a specific amount of time in one line

97 views Asked by At

A wordpress contact form plugin (contact form 7) allows us to use a snippet after the form is sent. The help states that we can use it like this:

on_sent_ok: "alert('sent ok');"

I'm using this snippet, to hide a div after the message is sent successfuly and it works:

on_sent_ok: $(".popmake").hide();

What I need to do is make this action to be taken after a specific amount of time like 2000 miliseconds after the message is sent (or the send button is clicked, whatever). Is it possible to do it in one line ?

I've almost no knowledge of Javascript, I got this line from other questions in here but couldn't figure out to delay it. I appreciate all helps.

Cheers!

Solved:

on_sent_ok: setTimeout(function() {$(".popmake").hide();},2000); 

Thanks a lot @jordumus!

0

There are 0 answers