<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <script type="text/javascript" src="http://jquery-api-zh-cn.googlecode.com/svn/trunk/style/lib/jquery.js"></script></head>
<body>
<a href="#" onclick="alert('1');return false;">哈哈</a>
<a href="#" onclick="alert('2');return false;">哈哈2</a> <script type="text/javascript">
$.map($("a"), function(item, index) {
$(item).click();
//为什么这里 item.click()不行呢? item应该直接就为HTML DOM对像啊
})
</script>
<script type="text/javascript">
for (var a in $("a")) {
alert(a);
//这里的a为什么是属性
//$("a")这里不是得到数组吗?
//var a in $("a") 应该是循环得到的数组啊,但这里不是
//为什么
}
</script></body>
</html>
for (var a in $("a")) {
//alert(a);
//这里是属性
}for (var i=0;i<$("a").length;i++) {
//alert($("a")[i]);
//这里是数组
}
2 闭包的关系,$(xx)得到的是jquery自身, a 是jquery中定义的属性
$("a")
不是得到他们的数组吗?
-------------------
闭包的关系,$(xx)得到的是jquery自身, a 是jquery中定义的属性
RE:不是很理解
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <script type="text/javascript" src="http://jquery-api-zh-cn.googlecode.com/svn/trunk/style/lib/jquery.js"></script></head>
<body>
<a href="#" onclick="alert('1');return false;">哈哈</a>
<a href="#" onclick="alert('2');return false;">哈哈2</a> <script type="text/javascript">
$.map($("a"), function() {
$(this).click();
})
</script>
</body>
</html>
$("a").each(function(){
$(this).click();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <script type = "text/javascript" src="http://jquery-api-zh-cn.googlecode.com/svn/trunk/style/lib/jquery.js"></script>
<script type = "text/javascript" src = "http://kingfishers.googlecode.com/svn/trunk/Kingfishers/kingfishers/logger.js"></script>
</head>
<body>
<a href="#" onclick="alert('1');return false;">哈哈</a>
<a href="#" onclick="alert('2');return false;">哈哈2</a> <script type="text/javascript">
$.map($("a"), function(item, index) {
$(item).click();
$alert($(item));
//为什么这里 item.click()不行呢? item应该直接就为HTML DOM对像啊
})
</script>
<script type="text/javascript">
$alert($("a"),"white");
for (var a in $("a")) {
$alert(a,"red");
//这里的a为什么是属性
//$("a")这里不是得到数组吗?
//var a in $("a") 应该是循环得到的数组啊,但这里不是
//为什么
}
</script></body>
</html>