funbinod Posted December 16, 2014 Share Posted December 16, 2014 how can I run something before the whole document becomes ready using jquery? I know d use of $(document).ready function. but I wish something happen before it. Link to comment Share on other sites More sharing options...
Ingolme Posted December 16, 2014 Share Posted December 16, 2014 The first question is: Why? The document does not take very long to load, if you were using the window's onload event then you would have to wait for all the images to load first, but document.ready just waits for the HTML to load before firing. There is no event prior to the ready state. If you want a script to run immediately after a particular element has loaded, put the script tags the first thing inside that element or if it's an empty element, put the script tags immediately after it. If your script is in the <head> and does not have any event handlers, it will run immediately, but be warned that that script will not have access to any elements on the page because they have not yet loaded. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now