<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> row-to-column conversion </title>
<Script type = "text/javascript" src = "jquery-1.4.2.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
Var trs = $ ("# table tr ");
Var tdLength = $ ("# table> tbody> tr: eq (1)> td"). length;
$ ("# Rc" pai.html ("rows:" + trs. length + "\ t columns:" + tdLength );
Var times = new Array ();
$ ("# Row2col"). click (function (){
Var begin = new Date ();
Var newTable = $ ("<table> </table>" ).css ({"border": "1px red solid"}). attr ("border", "1 ");
NewTable. appendTo ($ ("# show "));
For (var I = 0; I <tdLength; I ++ ){
Var tr = $ ("<tr> </tr> ");
Trs. each (function (index ){
Var td = $ ("td: eq (" + I + ")", $ (this ));
Tr. append (td. clone ());
});
NewTable. append (tr );
}
Var end = new Date ();
Var totalTime = end. getTime ()-begin. getTime ();
Times. push (totalTime );
$ ("# Time"). append ("times:" + totalTime + "<br/> ");
$ ("# AvgTime" functions .html (function (){
Var totals = 0;
Var count = times. length;
For (var I in times ){
Totals + = times [I];
}
Return "Average time:" + (totals/count) + "mm ";
});
});
});
</Script>
</Head>
<Body>
<Input type = "button" value = "row2col" id = 'row2col '/>
<Div id = "rc"> </div>
<Div id = "time"> </div>
<Div id = "avgTime"> </div>
<Div id = 'show'>
</Div>
<Table border = "1" id = "table">
<Tr>
<Td> 1 </td>
<Td> 2 </td>
<Td> 3 </td>
<Td> 4 </td>
</Tr>
<Tr>
<Td> 1 </td>
<Td> 2 </td>
<Td> 3 </td>
<Td> 4 </td>
</Tr>
<Tr>
<Td> 1 </td>
<Td> 2 </td>
<Td> 3 </td>
<Td> 4 </td>
</Tr>
</Table>
</Body>
</Html>
From longnihao's column