Html row-to-column Conversion

Source: Internet
Author: User

<! 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.