码迷,mamicode.com
首页 > 其他好文 > 详细

$.each

时间:2017-09-09 18:05:22      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:数组   lis   func   一个   tin   data   each   color   ble   

function(index,element)

必需。为每个匹配元素规定运行的函数。

  • index - 选择器的 index 位置//并非必须
  • element - 当前的元素(也可使用 "this" 选择器)

 

例:有一个ajax.post返回的json数组data

 

1 $(data).each(function(i,n){
2     alert("下标:"+i);
3     alert("值:"+n);
4 });

 

 

 1 $(function(){
 2         alert("index+++");
 3         $.post("product/manu",{
 4             "ID" : "1"
 5         },function(data){
 6             alert("data++++" + date);
 7             $(data).each(function(i,n){
 8                 w1 = ‘<option value="‘+n.mid+‘">‘+n.mname+‘</option>‘;
 9                 $("select:last").append(w1);
10             });
11         },"json");
12     });

 

$.each

标签:数组   lis   func   一个   tin   data   each   color   ble   

原文地址:http://www.cnblogs.com/tongs/p/7498650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!