jqeury 遍历函数的使用

来源:互联网 发布:sql指定的账户已存在 编辑:程序博客网 时间:2024/06/03 04:58

1、遍历document中的form 

第一种方法 根据标签名称来遍历:

$("form").each(function(){

alert(this.id);//form的id

});  //form为标签名

第二种方法去document中查询标签名为form的元素 :

$(document).find("form").each(function(){
alert(this.id);//form 的Id
});

2、遍历form中的元素 

$("input:text",form).each(function(){alert(this.name)});//其中form为jquery的form对象 input:text意思是遍历的元素为文本框,这个可以根据需要来改变

3、遍历函数

$(selector).each(function(index,element))//index 选择器的索引位置 element 当前的元素(也可使用“this”选择器)

$(selec

0 0
原创粉丝点击