zoukankan      html  css  js  c++  java
  • 全选、全部选、反选、提交

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <form>
            <input type="checkbox" name="items" value="足球">足球
            <input type="checkbox" name="items" value="篮球">篮球
            <input type="checkbox" name="items" value="羽毛球">羽毛球
            <input type="checkbox" name="items" value="并棒球">并棒球
            <input type="button" id="CheckedAll" value="全选">
            <input type="button" id="CheckedNo" value="全不选">
            <input type="button" id="CheckedRev" value="反选">
            <input type="button" id="send" value="提交">
        </form>
        
    </body>
    <!-- <script type="text/javascript" src="js/jquery-3.2.1.js"></script> -->
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#CheckedAll").click(function(){
                $('[name=items]:checkbox').attr('checked',true);
            });
            $("#CheckedNo").click(function(){
                $("[name=items]:checkbox").attr('checked',false)
            });
            $("#CheckedRev").click(function(){
                $("[name=items]:checkbox").each(function(){
                    // $(this).attr("checked",!$(this).attr("checked"))
                    this.checked=!this.checked;
                })
            });
            $("#send").click(function(){
                var str="你选中的是:
    ";
                $('[name=items]:checkbox:checked').each(function(){
                    str+=$(this).val()+"
    ";
                });
                alert(str)
            })
        })
    </script>
    </html>
  • 相关阅读:
    CentOS6.8下安装Docker
    xshell连接Linux(centos6.8)失败的解决方法
    Windows Server定时执行bat
    [译]看漫画学Flux
    LeetCode题型分类及索引
    LeetCode & Q38-Count and Say-Easy
    LeetCode & Q20-Valid Parentheses-Easy
    LeetCode & Q14-Longest Common Prefix-Easy
    LeetCode & Q13-Roman to Integer-Easy
    LeetCode & Q28-Implement strStr-Easy
  • 原文地址:https://www.cnblogs.com/jinsuo/p/7422735.html
Copyright © 2011-2022 走看看