Skip to content

Instantly share code, notes, and snippets.

@acdcjunior
Created October 19, 2022 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdcjunior/10f78faf114c6426a8b103cf54e508d1 to your computer and use it in GitHub Desktop.
Save acdcjunior/10f78faf114c6426a8b103cf54e508d1 to your computer and use it in GitHub Desktop.
jquery document ready window load
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"
></script>
</head>
<body>
<pre id="out"></pre>
<script type="text/javascript">//<![CDATA[
const go = (s) => out.innerHTML += '\n' + s;
go('out1');
$(document).ready(function(){
go('r1');
$(window).on('load hashchange', function(event) { go('LH'); });
$(window).on('load', function(event) { go('LL'); });
$(window).on('hashchange', function(event) { go('HH'); });
$(window).on('pageinit', function(event) { go('PI'); });
go('r2');
});
go('out2');
$(window).on('load', function(event) { go('LOUT'); });
//]]></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment