javascript - Jquery how do i perform a class change function before the next click -
i have bit of script data , puts in class called .tile-area-main
i need able know how delay entire click introduce new class animation run seconds before moving on new click.... how go ? ...
(i sure timeout add class kinda have been researching)
the script in question
$(document).ready(function() { $("body").on("click", ".slide", function(e) { e.preventdefault(); var url = $(this).attr('data-url') + ' #' + $(this).attr('data-target'); $('.tile-area-main').load(url); }); });
you need use settimeout
calls function or executes code snippet after specified delay.
code
$("body").on("click", ".slide", function(e) { e.preventdefault(); //remove , add required classs $(yourelement).removeclass('a').addclass('b'); //delay execution of load settimeout(function(){ var url = $(this).attr('data-url') + ' #' + $(this).attr('data-target'); $('.tile-area-main').load(url); }, 1000); //time interval in milliseconds });
Comments
Post a Comment