<code class="language-html">
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,userscalable=no" />
<link href="../css/mui.min.css" rel="stylesheet" />
</head>
<body>
<input name="aaa" type="hidden" value="111" /> <input name="bbb" type="hidden" value="222" /> <input name="ccc" type="hidden" value="333" /> <input name="ddd" type="hidden" value="444" /> <script src="../js/mui.min.js</script> <script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
mui.init() //处理一维数组
var arr1 = ["aaa", "bbb", "ccc"];
$.each(arr1, function(i, val) { console.log(i + val);}); //处理二维数组
var arr2 = [
['a', 'aa', 'aaa'],
['b', 'bb', 'bbb'],
['c', 'cc', 'ccc']
];
$.each(arr2, function(i, item) { console.log(i + "====" + item); $.each(item, function(j, val) { console.log(j + "====" + val)
});
}); //处理json数据
var obj = {
one: 1,
two: 2,
three: 3
};
$.each(obj, function(key, val) {
console.log(key + "===" + val)
})//处理dom元素
$.each($("input:hidden"), function(i, val) {
console.log("i===" + i)
console.log(val.name)
console.log(val.value)
})
</script>
</body>
</html>
</code>
jQuery $.each()常见的几种使用方法
还不快抢沙发
最新回复
haha: 887878
refewf: wefewfre
refewf: ededededeed