The method you choose will depend on your goals. If you simply want to reset all td elements to their default width simultaneously, you can use the CSS property width: auto
. However, if you intend to animate the width changes, the process becomes a bit more intricate. You will need to store the initial width of each column in a variable and then animate it to its original size.
For a detailed example, refer to this updated jsFiddle demonstration: http://jsfiddle.net/k2Pqw/5/
$(document).ready(function () {
var blaW = $('#bla').width(), beW = $('#be').width();
$("#bla").animate({ width: "500px" }, 1000, function () {})
.animate({width: blaW+'px'}, 1000, function () {});
$("#be").delay(2500)
.animate({ width: "500px" }, 1000, function () {})
.animate({width: beW+'px' }, 1000, function () {});
});
Here is the HTML code:
<table id="myTable">
<tr>
<td style="background-color:Aqua;">salamander</td>
<td style="background-color:Red;" id="bla">s</td>
<td style="background-color:Black;" id="be">s</td>
<td style="background-color:Green;">s</td>
</tr>
</table>