Only perform jquery effects/operations on certain pages
Posted
by Galen
on Stack Overflow
See other posts from Stack Overflow
or by Galen
Published on 2010-04-30T16:02:25Z
Indexed on
2010/04/30
16:07 UTC
Read the original article
Hit count: 374
Up until now i've been dropping all my jquery code right inside the document.ready function. I'm thinking that for certain situations this isnt the best way to go.
for example: If i want an animation to perform when a certain page loads what is the best way to go about that.
$(document).ready(function() {
$("#element_1").fadeIn();
$("#element_2").delay('100').fadeIn();
$("#element_3").delay('200').fadeIn();
});
If this is right inside of document.ready then every time ANY page loads it's going to check each line and look for that element. What is the best way to tell jquery to only perform a chunk of code on a certain page to avoid this issue.
© Stack Overflow or respective owner