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方法如下:
. 代码如下:
window.onload = function() {
$("table tr:nth-child(even)").addclass("even"); //这个是jquery代码
};
但是用jquery的方法:
. 代码如下:
$(document).ready(function() {
// 任何需要执行的js特效
$("table tr:nth-child(even)").addclass("even");
});
还有一种简写的方式:
. 代码如下:
$(function() {
// 任何需要执行的js特效
$("table tr:nth-child(even)").addclass("even");
});
如对本文有疑问, 点击进行留言回复!!
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
CTF 刷题记录(一) 白云新闻搜索(手动与自动化SQL注入)
javascript如何使用函数random来实现课堂随机点名方法详解
网友评论