$("<caption>"+$("title")[0].innerHTML+"</caption>").appendTo($("table")); $('table').attr('border',1); $('table').click(function(){ $("th:nth-child(even)").after($("th:nth-child(odd)")); $("td:nth-child(even)").after($("td:nth-child(odd)")); }) $('caption').click(function(){ $(this).empty(); })
<table> <tr> <th>Column 1 Heading</th> <th>Column 2 Heading</th> </tr> <tr> <td>Row 1: Col 1</td> <td>Row 1: Col 2</td> </tr> </table>