1. There are three ways to initialize jQuery page loading. The script will be executed when the page is loaded. There should be no difference. It mainly depends on the habit. I think the second method is the best and more concise.
Note: If the js initialization html code is written above html, the page loading order is: html template -> js code -> html data; if the js initialization html code is written below html, the page loading order is: html Template->html data->js code
If you
need the html page to display all the background data before operating, you need to write the js code behind the html. The first type:
$(document).ready(function(){ });
The second:
$(function(){ });
The third:
jQuery(function($) { });
Second, js in the page initialization method
The first:
<script> window.onload=function(){ var tb=document.getElementByIdx_x("DataGrid1"); var cbs=tb.getElementsByTagName_r("input"); for(var i=0;i<cbs.length;i++) { if(cbs[i].type=="checkbox") { cbs[i].checked=true; } } } </script>
The second:
function ckCbo() { document.getElementByIdx_x('cboTest').cheacked=true } <body onload='ckCbo()'>