传说中新增table最快的方法

代码
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
    
< title > 无标题页 </ title >
    
< style  type ="text/css" >
        .style1
        
{
            width
:  100% ;  border : 1 ;  border-color : Red ;
        
}
        td
{}
        .style2
        
{
            width
:  100% ;
            border-collapse
:  collapse ; border-color : Red ;
        
}
         .style2 td
{  border : 1px red dotted }
    
</ style >
</ head >
< body >

  

    
< table  class ="style2"  border ="1" >
        
< tr >
            
< td >
                
&nbsp; </ td >
            
< td >
                
&nbsp; </ td >
        
</ tr >
        
< tr >
            
< td >
                
&nbsp; </ td >
            
< td >
                
&nbsp; </ td >
        
</ tr >
    
</ table >
< div  id ="tableDiv" ></ div >
< script  type ="text/javascript" >
  
var  maxRow  = 30 ;
  
var  maxCol  =   8 ;
  
var  strTbody  =  [ " <table border='1' class='style2'><tbody> " ];
 
  
for ( var  i  =   0 ; i  <  maxRow; i ++ ){
  strTbody.push(
" <tr> " );
   
for ( var  j  =   0 ; j  <  maxCol; j ++ ){
   strTbody.push(
" <td>test</td> " );
   }
  strTbody.push(
" </tr> " );
  }
 
  strTbody.push(
" </tbody></table> " );
 
  
var  obj  =  document.getElementById( " tableDiv " );
  obj.innerHTML 
=  strTbody.join( "" );
 
</ script >
</ body >
</ html >

 

你可能感兴趣的:(table)