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变量不可以用这一句话
                         }
                     );
                 }
              } 

  • 相关阅读:
    java学习疑问
    HTTP method GET is not supported by this URL
    详解ListView分页(带图片)显示用法案例
    MySQL 字段数据类型/长度
    getRequestDispatcher()与sendRedirect()的区别
    Codeforces Round #754 (Div. 2) D,E 题解
    CCPC2019 Harbin Site B.Binary Numbers
    2020 EC Final D. City Brain
    [USACO15JAN]Grass Cownoisseur G
    CF1295F Good Contest
  • 原文地址:https://www.cnblogs.com/lmfeng/p/2231570.html
Copyright © 2011-2022 走看看