jQuery each()学习一下
来源:互联网 发布:淘宝瑜伽服模特是谁 编辑:程序博客网 时间:2024/06/05 05:25
jQuery each()小议
代码如下:
var arr1 = [ "one", "two", "three", "four", "five" ];$.each(arr1, function(){
alert(this);
});
输出:one two three four five
var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){ 参数的名字可以自己定义,each方法会根据第一个参数(arr2)的格式而判断回调函数方法体语法的正确性
alert(item[0]);
});
输出:1 4 7
var obj = { one:1, two:2, three:3, four:4, five:5 };
$.each(obj, function(key, val) {
alert(obj[key]);
});
输出:1 2 3 4 5
$.each($("input:hidden"), function(){
alert(this.name);
});
$.each($("input:hidden"), function(){
alert(this.value);
});
跳出遍历
代码如下:
function test()
{ var index=0;
var arr1 = [[1, 4, 3], [4, 6, 6], [7, 20, 9]]
$.each(arr1, function(i,item){
if(i==1)
{
alert("点击继续下次遍历");
return ; //return false ;则跳出遍历
}
alert('索引'+i+'_'+item[0]);
});
})
- jQuery each()学习一下
- JQuery学习之each方法
- jQuery 学习笔记之$.each()
- jQuery学习03---map,each方法学习
- JQuery 学习—$.each遍历学习
- jQuery.each()与each()
- JQuery遍历-$.each()||$().each()
- jQuery学习(一)----each遍历&&hasClass属性
- jQuery源码学习 之 each迭代器
- jQuery学习(一)----each遍历&&hasClass属性
- JQUERY Each
- jquery each
- JQUERY/EACH()
- jquery each
- jQuery(each())
- jquery each()
- jquery each
- jquery each
- Windows精准计时&精准Timer
- About MVCPager 分页
- Apache组件commons的IO包常用方法实例
- hdu 3586 树形dp +二分
- inline在C++中的作用(转)
- jQuery each()学习一下
- UVALive 6039 Let's Go Green (贪心)
- QT学习1 QSlider 更改样式 .
- Delete it解题报告
- DB2中SQLSTATE=57016 SQLCODE=-668,原因码 "7"的解决
- 黑马程序员____基础加强____静态导入&可变参数&增强for循环
- ajax 防止用户反复提交
- oracle常用sql语句(综合)
- ios 重用UITableViewCell created from a XIB