zoukankan      html  css  js  c++  java
  • jquery选中checkbox


    jquery选中checkbox:
    $(function(){
    $("[value = bb]:checkbox").attr("checked", true);//$("[name = sortid]:eq(0)").attr("checked", true); check the first radio
    });
    选中的个数:
    $("input[name = myname]:checked").length

    <script type="text/javascript">

    $(function(){
    $("[value = bb]:checkbox").attr("checked", true);
    });

    function judgecheckbox(){
    $("input[type='checkbox']").attr('name');
    if($("input[name=myname]:checked").length==0) //获得选中的数量
    {
    alert("请选择分类信息");
    return false;
    }
    return true;
    }

    </script>
    </head>

    <body>
    This is my JSP page.
    <br>

    <form>
    我喜欢自行车: <input type="checkbox" name="myname" value="aa" > <br />
    我喜欢汽车: <input type="checkbox" name="myname" value="bb">
    <a onclick="judgecheckbox()">查看</a>
    </form>

    </body>
    </html>

  • 相关阅读:
    Mysql其他
    Linux大全
    Django-你想知道的都在这里
    k8s
    极速安装k8s 快速融入学习
    flask orm
    Elasticsearch
    1爬虫
    MY git 操作
    docker 骚操作
  • 原文地址:https://www.cnblogs.com/tshua/p/5709723.html
Copyright © 2011-2022 走看看