zoukankan      html  css  js  c++  java
  • Jquery的集合方法EACH()

    Jquery的集合方法EACH()
    1、
    $("input[name='r2']").each(function(){
        if($(this).val()=='lmf')
        {
            this.checked = true;
        }  
    })

    2、
    $("input[name='r2']").each(function(){
        this.checked = this.value == "lmf";
    })

    3、
    $("input[name='r2']").each(
        function(i,item){
            if(item.value=='lmf')
            {
                item.checked = true;
            }
        }
    )

    4、
    $.each(list,function(i,item){

    })
    有时候function的参数不能省略:

             if(!StringUtils.IsNullOrEmpty(liveStatus))
             {
                 lives = liveStatus.split(",");
                 var len = lives.length;
                 var i = 0;
                 for(i=0;i<len;i++)
                 {
                     $("input[name='ck_LiveStatus']").each(
                         function(k,item) {
                             if(item.value == lives[i])
                             {
                                 item.checked = true;
                             }
                             //this.checked = this.value == lives[i];因为里面有i变量不可以用这一句话
                         }
                     );
                 }
              } 

  • 相关阅读:
    利用 PHP 导出 Git 某个分支下,新增或修改过的文件
    [翻译] 10 个实用的 Git 高级命令
    Django web project
    install virtualenv
    js原型继承
    HTML 学习杂记
    IDEA 文件列表隐藏某后缀文件
    coocsCreator杂记
    mac install brew
    c编程:输入一个数字n,则n代表n行,每行输入2个数字a,b计算每行的a+b问题。
  • 原文地址:https://www.cnblogs.com/lmfeng/p/2231570.html
Copyright © 2011-2022 走看看