zoukankan      html  css  js  c++  java
  • checkbox:获取选中的checkbox

    checkbox:获取选中的checkbox

    1,
    function CheckInput() {
    var _nCount = 0;
    $("#box1").find(":checkbox:checked").each(function () {
    _nCount++;
    });
    }
     

    2.,if (!$("input[type='checkbox']").is(':checked')) {
    top.alert("请您选择变更申请项目");
    return false;
    }

    3,$('#file tr td .point').each(function () {

    var li = $(this).parents('tr').find('.f_l_c');
    var html = $(this).parents('tr').find('td').eq(1).find('span').html();
    if (li.length == 0) {
    top.alert("请上传'" + html + "'附件");
    ReStr = false;
    return ReStr;
    }
    });

    4,有多个checkbox,选出第一个选中的checkbox:

     
        $("#btn").click(function () {            
            //选择checkbox前面加冒号,选中属性前加冒号
            var checks = $("#table2 :checkbox:checked");
            if (checks.length > 0) {  
            //eq是第几个,从0开始                
                var sid = checks.eq(0).parent().parent().attr("id");
                alert(sid);
            }
            else {
                alert("你没有选择");
            }
        });
     

    页面结构:

     
        <input type="button" id="btn" value="单击" />
        <table id="table2">
        <tr guid="ed2d15679cce4100b7ad4a4f27bf8f02" num="11" id="108580">
        <td style=" 20px; color: rgb(0, 0, 0);"><input type="checkbox" value="108580" name="id"></td>
        </tr>
        </table>

  • 相关阅读:
    webpack的基本使用2
    js调用本地exe程序,并获取exe运行结果
    BLE技术简介(转)
    在线编解码转换工具
    json字符转数组
    PPT图标
    在线IP地址与数字互转工具
    C# Combobox
    C# 设置本机日期格式
    sql server删除字段约束
  • 原文地址:https://www.cnblogs.com/wyBlog117/p/4604004.html
Copyright © 2011-2022 走看看