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