Several ways Jquery executes after a page loads

  • 2020-03-30 02:23:27
  • OfStack

Method 1:
 
$(function(){ 

initPublish(); 

}); 

InitPublish () is the JS function you want to run. This code is at the bottom of the page.

Method 2:
 
$(document).ready(function () { 

// add your code here 

initPublish(); 

$(.a).click( function (){ 

// add your code here 

}); 

}); 

Method 3:
 
window.onload = function (){ 

// add your code here 

} 

Related articles: