Any ideas to disordering a table?
Hi, I'm new at the forum and new in jQuery.
I have to alter randomly the order of the td elements of a table. Do you have any idea to do it "quickly"?
My initial idea is:
- Clone the original table (I can't modify it).
- Disorder randomly the elements of the cloned table.
- Show the cloned table.
The actual code is:
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
-
- <script type="text/javascript">
- $(document).ready(function(){
-
- });
- </script>
- </head>
-
- <body>
-
- <script>
- $(document).ready(function(){
- <!-- We make the copy of the table
- $('#data-source tr')
- .clone()
- .appendTo("#new_table")
- ;
- <!-- We show the copied table down the original (for testing purposes)
- $('#new_table').css('display', 'block');
- $('#data-source').css('display', 'block');
- });
- </script>
- <!-- ini data-source -->
- <div id="data-source-container">
- <table id="new_table"></table>
- <table id="data-source">
- <tr>
- <td>First element.</td>
- <td>Second element.</td>
- <td>Third element.</td>
- <td>Fourth element.</td>
- <td>Fifth element.</td>
- </tr>
- </table>
- </div>
- <!-- end data-source -->
- </body>
- </html>
Can someone help me a bit disordering the elements?
Thank you very much, and sorry for my english.