I need to alternate a date and a phrase within a <table> cell without using fixed width.
<table>
<thead>
<tr><th>Date</th></tr>
</thead>
<tbody>
<tr><td id='changethis'>Wed Dec 21 2011</td></tr>
</tbody>
</table>
var hold = $('#changethis').text();
setInterval(function () {
if ($('#changethis').hasClass("highlight")) {
$('#changethis').text(hold);
$('#changethis').removeClass("highlight");
}
else {
$('#changethis').text(" E R R O R ");
$('#changethis').addClass("highlight");
}
},1000);
The problem is the table reformats the width of the column every time the text alternates. Is it possible to calculate rendered text width and adjust the alternating text accorrdingly?? JSbin Here
you could try adding the width to the element
http://jsbin.com/ozunan/3/edit