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 -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -