jq each遍历数组或对象

发布时间:2019-08-12 22:00:11发布者:Mr.Zhang阅读(66)

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);
  });
}





本文转自博客园,原文地址:https://www.cnblogs.com/wangjian66/p/11341710.html