Question

I need a little guidance. I am trying to delay the execution of these two functions until after the page is fully loaded or timebomb them to happen after 5000 ms.

I am using the latest jquery 1.6

Thank you in advance for your help and code snippits :)

$("a.siteNavLink").each(function() {
   var _href = $(this).attr("href"); 
   $(this).attr("href", _href + '?p=client');
});
$("a.footernav").each(function() {
   var _href = $(this).attr("href"); 
   $(this).attr("href", _href + '?p=client');
});
Was it helpful?

Solution

$(document).ready(function() {
  // Your code here
});

That will make your code run only when the document is fully loaded

jQuery ready() documentation

OTHER TIPS

You can use

$(window).load(function(){ your code here }) // page has loaded including images 

or

$(document).ready(function(){ your code here }) // dom has loaded 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top