JQuery自动为表格增加一列

阅读更多

JQuery自动为表格增加一列_第1张图片

JQuery自动为表格增加一列_第2张图片

 

复制代码
<%@ Page Language= " C# " AutoEventWireup= " true " CodeFile= " test.aspx.cs " Inherits= " test " %>

" -//W3C//DTD XHTML 1.0 Transitional//EN "  " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

" http://www.w3.org/1999/xhtml ">  
  
      
    " js/jquery-1.4.1.min.js " mce_src= " js/jquery-1.4.1.min.js " type= " text/javascript ">
    " text/javascript ">
         function addCol() {  
            $col = $( " 增加的列 ");  
            $( " #tab1>tbody>tr ").append($col);  
        }  
        function delCol() {  
             // 移除最后一列  
            $( " #tab1 tr :last-child ").remove();  
             // 移除第一列  
            
// $("#tab1 tr :first-child").remove();  
            
// 移除指定的列, 注:这种索引从1开始  
            
// $("#tab1 tr :nth-child(2)").remove();  
            
// 移除第一列之外的列  
            
// $("#tab1 tr :not(:nth-child(1))").remove();  
        }  
    
 
  
  
    " Button1 " type= " button " onclick= " addCol() " value= " 增加列 " />  
    " Button2 " type= " button " onclick= " delCol() " value= " 减少列 " />  
    " tab1 " border= " 1 " style= " width: 200px; ">  

          
              
                  1  
                 hello  
              
              
                 2  
                world  
              
              
                 3  
                王子饼  
            
          
      
  
 

你可能感兴趣的:(JQuery自动为表格增加一列)