Created
September 23, 2014 00:19
-
-
Save htmlr/7be4ad6cf13ef190b63c to your computer and use it in GitHub Desktop.
Detecting DOM ready in jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // If the DOM is already ready | |
| if ( jQuery.isReady ) { | |
| // Execute the function immediately | |
| fn.call( document, jQuery ); | |
| } // ... | |
| function myClickHandler(event) { | |
| // do stuff | |
| $(document).ready(function() { | |
| // Do this immediately if DOM is loaded, or once it's loaded otherwise. | |
| } | |
| } | |
| $(document).ready(function() { | |
| window.domIsReady = true; | |
| } | |
| if (window.domIsReady) { | |
| // do stuff | |
| } | |
| $(document).ready(function() { | |
| // Handler for .ready() called. | |
| }); | |
| $(document).ready(function() { | |
| alert ("document is ready!"); | |
| }); | |
| jQuery(document).ready(function(){ | |
| alert("howdy"); | |
| }); | |
| <script type="text/javascript"> | |
| if (typeof jQuery == 'undefined') | |
| { | |
| alert('not loaded'); | |
| } | |
| </script> | |
| <script type="text/javascript"> | |
| if(!this.$) | |
| { | |
| alert('not loaded'); | |
| } | |
| </script> | |
| $(document).ready(function(){ | |
| alert('document ready here') | |
| }); | |
| $(window).load(function(){ | |
| alert("All content has been downloaded to the web browser") | |
| }); | |
| function doStuff() { | |
| alert("The DOM and everything inside have loaded"); | |
| } | |
| window.onload = doStuff; | |
| $(document).ready(handler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment