zoukankan      html  css  js  c++  java
  • checkbox限制选中个数

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <link href="sysStyle.css" type="text/css" rel="stylesheet"/>
    <link href="../crm-css/search.css" type="text/css" rel="stylesheet"/>
    <script src="jquery-1.7.2.js" type="text/javascript"></script>
    <script type="text/javascript">

    $(document).ready(function() {

      var isChk=$('#'+idd).is(':checked');//判断是否被选中

    $('input[type=checkbox]').click(function() {

    $("input[name='apk[]']").attr('disabled', true);

    if ($("input[name='apk[]']:checked").length >= 3) {

    $("input[name='apk[]']:checked").attr('disabled', false);
    alert("选中超过三个");

    } else {

    $("input[name='apk[]']").attr('disabled', false);

    }

    });

    })

    </script>

    <ul>

    <li>

    <input type="checkbox" name="apk[]" value=1 />

    APK1

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=2 />

    APK2

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=1 />

    APK3

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=4 />

    APK4

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=6 />

    APK5

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=7 />

    APK6

    </li>

    <li>

    <input type="checkbox" name="apk[]" value=8 />

    APK7

    </li>

    </ul>

  • 相关阅读:
    一个主机下创建两个MySQL
    Chrome: Failed to read the 'localStorage' property from 'Window' 的解决办法
    Effective C++
    归并排序
    Daily Note
    关于Beta分布、二项分布与Dirichlet分布、多项分布的关系
    测试公式
    VLAN原理解释
    子网划分
    windows下制作debian U盘启动
  • 原文地址:https://www.cnblogs.com/yy123/p/4011685.html
Copyright © 2011-2022 走看看