2

I am working on a page where javascript from various sources is being executed .

I want to ensure my custom js is only executed AFTER everthing else has been done .

The "other" js is call on various events like clicking some buttons etc ..all of which change/alter the Dom in some way .I want to detect in my custom js when this DOM change is complete I want to do something(which may also change the DOM but thats fine as it may result into execting my js twice which i can afford ) But the main question is how to I know that the other js is done with the DOM ?

nitin_sh
  • 83
  • 1
  • 9

1 Answers1

3

You can put your code inside DOM ready handler:

$(document).ready(function() {
     // Code goes here
});

If you want to run code once the entire page (images or iframes), not just the DOM, is ready, then use:

$( window ).load(function() { 
    // Code goes here 
})
Felix
  • 37,892
  • 8
  • 43
  • 55
  • these handler would only work (correct me if i am wrong) when the DOM is ready for the first form load .My requirement is as @Patrick Evans said is ondomchanged event which can be triggered anytime on the page I need to capute that and re run my code every time that happens . – nitin_sh Feb 14 '14 at 08:59
  • @user2319373 I think there's no way you can achieve it.... – Felix Feb 14 '14 at 09:02