Call a function inside another function on document load - Javascript jQuery

Javascript examples for jQuery:Document

Description

Call a function inside another function on document load

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  www . j  av a2 s  .c  om*/
function my() {
        console.log('my second alert')
}
function test() {
    console.log('my first alert');
    my();
}
$(document).ready(function(){
    test();
})
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials