2. window.onload = function () {alert("onload");}
Onload() event will be called only after the DOM and associated resources like images got loaded
3. JQuery $(document).ready(handler)
jQuery's document.ready() event will be called once the DOM is loaded, it wont wait for the resources like images to get loaded
All three of the following syntaxes are equivalent:
- $(document).ready(handler)
- $().ready(handler) (this is not recommended)
- $(handler)
Reference:
http://api.jquery.com/ready/
If useful, Consider making a donation to show your support.