Jquery Add a delay in P text swap -


$(document).ready(function() {     $("p").on("click", function() {         var el = $(this);         if (el.text() == el.data("text-swap")) {             el.text(el.data("text-original"));         } else {             el.data("text-original", el.text());             el.text(el.data("text-swap"));         }     }); }); 

is possible add delay in jquery code?

use settimeout

sets timer executes function or specified piece of code once after timer expires.

$(document).ready(function() {     $("p").on("click", function() {         var el = $(this);         settimeout(function() {             if (el.text() == el.data("text-swap")) {                 el.text(el.data("text-original"));             } else {                 el.data("text-original", el.text());                 el.text(el.data("text-swap"));             }         }, 1000);     }); }); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -