1、$(function(){
$("#a").click(function(){
//adding your code here
});
});
2、$(document).ready(function(){
$("#a").click(function(){
//adding your code here
});
});
3、window.onload = function(){
$("#a").click(function(){
//adding your code here
});
}
html代碼為<input type="button" id="a">點擊</input>,且頁面需要引用jquery的js文件
一般的加載頁面時調用js方法如下:
但是用jquery的方法:
還有一種簡寫的方式:
新聞熱點
疑難解答