Jquery .each() 应用
<!DOCTYPE html>
<html xmlns="http://www.w3.org/xhtml/1999">
<head>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript">
var a = ['aaaa','bbbb','cccc'];
$.each(a,function(i,val){
alert( typeof(a)+"---> "+i+" : "+typeof(val)+" : "+val);
});
</script>
</head>
<body>
</body>
</html>
理解:
var a = ['aaaa','bbbb','cccc']; // 数组
$.each(a,function(i,val){ //迭代
// i ---> 下标
// val ---> a[i]
alert( typeof(a)+"---> "+i+" : "+typeof(val)+" : "+val);
});
本文深入探讨了jQuery.each()函数在JavaScript数组遍历中的应用,详细解释了其参数i和val的作用,并通过实例代码展示如何使用该函数。
136

被折叠的 条评论
为什么被折叠?



