zoukankan      html  css  js  c++  java
  • web中的简单全选反选

    <html>  
    <body>  
        <table>  
            <tr>  
                <th><input type="checkbox" onclick="swapCheck()" id="check" /></th>  
                <th>全选</th>  
                <th><input type="checkbox" onclick="fanCheck()" id ="check1"/></th>  
                <th>反选</th>  
            </tr>  
            <tr>  
                <td><input type="checkbox" /></td>  
                <td>苹果</td>    
            </tr>  
            <tr>  
                <td><input type="checkbox" /></td>  
                <td>香蕉</td>    
            </tr> 
            <tr>  
                <td><input type="checkbox" /></td>  
                <td></td>    
            </tr>  
        </table>  
        <script type="text/javascript"  
            src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>  
      
        <script type="text/javascript">   
            var isCheckAll = false;  
            function swapCheck() {  
                if (isCheckAll) {  
                    $("input[type='checkbox']").prop('checked',false);
                    isCheckAll = false;  
                } else {  
                    $("input[type='checkbox']").prop('checked',true);
                    $("input[id='check1']").prop('checked',false);
                    isCheckAll = true;  
                }  
            }  
    
            function fanCheck() {
            $("input[type='checkbox']").each(function(){
            $(this).prop('checked',!$(this).prop('checked'));
            });
    
            $("input[id='check']").prop('checked',false);
            $("input[id='check1']").prop('checked',!$(this).prop('checked'));
            }  
        </script>  
    </body>  
    </html> 

    不知道用不用的到。。。。

  • 相关阅读:
    第一阶段站立会议7
    人机交互—对win10自带输入法的评价
    个人工作总结15
    构建之法阅读笔记06
    个人工作总结14
    第十三周工作总结
    个人工作总结13
    《梦断代码》阅读笔记02
    个人工作总结12
    小水王
  • 原文地址:https://www.cnblogs.com/huhu1203/p/7693620.html
Copyright © 2011-2022 走看看