欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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