jq each遍历数组或对象
程序员文章站
2022-06-24 09:00:24
var arr = ["北京","上海","天津","重庆","河北","河南","安徽","湖北","湖南"]; $.each(arr, function(i, val) { console.log(i+"-- --"+val); }); var obj= {name:"小明",male:"男"} ......
var arr = ["北京","上海","天津","重庆","河北","河南","安徽","湖北","湖南"];
$.each(arr, function(i, val) {
console.log(i+"-- --"+val);
});
var obj= {name:"小明",male:"男"};
$.each(obj, function(i, val) {
console.log(i+"-- --"+val);
});
function handle(param){
$.each(param, function(i, val) {
console.log(i+"-- --"+val);
});
}