zoukankan      html  css  js  c++  java
  • JQuery操纵table

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="../jquery-1.9.0.min.js"></script> 
    <title>Insert title here</title>
    <script type="text/javascript">
    $(function(){
        //var tr = $(" table  tr:odd").css("background-color","gray");
        
        $("table tr").each(function(){
            //alert($(this).find("td input").val());
            /* if($(this).find("td input").attr("type")=='checkbox'){
                $(this).find("td input").attr("disabled",true);
                //$(this).css("background-color","gray");
            } */
            callBack("b;d");
            
        });
        
        // apiData read only edit line
        function callBack(apiScids){
            removeStyle();
            if(apiScids == ""){
                return;
            }
            $("#bodys2  tr").each(function(){
                 if($(this).find("td input:eq(0)").attr("type") == "checkbox"){
                    var val = $(this).find("td input:eq(0)").attr("value");
                    if(val!=""){
                        if(apiScids.indexOf(val)>=0){
                            $(this).find("td").attr("disabled",true);
                        }
                    }
                } 
            });    
        }
        
        //移除样式
        function removeStyle(){
            $("#bodys2  tr").each(function(){
                if($(this).find("td:eq(0)").prop("disabled") == true){
                    $(this).find("td").attr("disabled",false);
                }
            });    
        }
        
    });
    
    </script>
    
    </head>
    <body>
    <table id ="bodys2">
    <tr><td><input type="checkbox"  value='a'/><input type="text"  value='aaa'/></td><td>aa<input type="text"  value='a'/><input type="text"  value='aaaaa'/></td></tr>
    <tr><td><input type="checkbox"  value='b'/><input type="text"  value='bbb'/></td><td>bb<input type="checkbox"  value='a'/><input type="text"  value='bbbb'/></td></tr>
    <tr><td><input type="checkbox"  value='c' /></td><td>cc<input type="checkbox"  value='a'/><td></tr>
    <tr><td><input type="checkbox"  value='d'/></td><td>dd<input type="checkbox"  value='a'/><td></tr>
    <tr><td><input type="checkbox"  value='e'/></td><td>ee<input type="checkbox"  value='a'/><td></tr> 
    </table>
    </body>
    </html>
  • 相关阅读:
    关于哈希表的一些资料
    ACM题目推荐(刘汝佳书上出现的一些题目)
    搜索引擎技术文章
    计算机体系结构文章摘选
    正则表达式语法
    三维地形显示
    无砝码天平3次称出12个小球中质量异常球问题
    关于char, wchar_t, TCHAR, _T(),L,宏 _T、TEXT,_TEXT(转)
    vcf文件分解
    Oracle 创建自动增加主键的表
  • 原文地址:https://www.cnblogs.com/lxh520/p/9178985.html
Copyright © 2011-2022 走看看