c9999
$("input[type=\'checkbox\']").each(function(){
	var value = $(this).val();      //获得值
	$(this).attr("checked",true);   //选中,不选中 是false			
});

 $.each() 遍历对象

$(document).ready(function () {
        var inputs = $("input[type=\'checkbox\']");
        $.each(inputs,function(p1,p2){     // 这里的p1 是 序号即下标
            alert(p1+p2.value);
            alert(p2.checked);
        })
    })

 

$.each(obj,fn(p1,p2){

})

 

obj:要遍历的对象

p1:下标(或是对象的属性)

p2:具体的对象(这里就是一个input)

 

 /*遍历数组*/
    $(document).ready(function () {
        var arrPerson = { "张三":"20","李四":"44" ,"王五":"51" };
        $.each(arrPerson,function (p1, p2) {    
            alert(p1+":"+p2);  // 结果是 :   张三:20    ,这里的p1 就不是序号了
        })
    })

  

域名购买.com 后缀好域名 

 https://mi.aliyun.com/shop/38040

 

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-12-10
  • 2021-12-02
  • 2021-11-14
  • 2021-12-26
  • 2021-11-02
猜你喜欢
  • 2021-09-25
  • 2021-12-10
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案