李小子
2016-08-18 15:01
//不同函数传递数据
function data(e) {
alert(e.data) //1111
}
function a() {
$("button:eq(2)").click(1111, data)
}
a();}
这个函数 $("button:eq(2)").click(1111, data)中data指的是上面的函数名吗?具体怎么执行的,麻烦大神解释下!
没错,data是指的 function data(e)这个函数。具体执行就是:在click事件中,将参数(1111)传入并调用data函数
尝试以下代码,能更直观的感受。。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>节点属性</title>
</head>
<body>
<ul>
<li>javascript</li>
<li>HTML/CSS</li>
<li>jQuery</li>
</ul>
<script type="text/javascript">
var nothing = document.getElementsByTagName("li");
var testFunc = function(){
alert(1);
};
nothing[0].onclick = testFunc();
// 尝试在testFunc后去掉括号的区别,nothing[0].onclick = testFunc;
</script>
</body>
</html>jQuery基础(三)—事件篇
89985 学习 · 645 问题
相似问题