Reputation: 207
Here's the code..
<td align="right" width="135">
<div align="right">
<font class="class123"><b>$9.67</b></font>
</div>
</td>
I have multiple instances of this cell in a table and would like to change the width of them all. I've tried things like...
jQuery(".class123").closest("tr").html();
And thought about swapping out all the html, but I don't think that's the best way. I need to do it for all the cells. Any ideas?
Upvotes: 1
Views: 5918
Reputation: 605
Let me know if i understood... You want to change all td width attribute right? Try this:
$('.class123').each(function(){
$(this).closest('td').attr('width', 500);
});
Upvotes: 0
Reputation: 539
html
<table>
<tr>
<td id="myRow"></td>
</tr>
jquery
$(document).ready(function () {
var newWidth = $("#myRow").width();
$("#myRow").width(newWidth*0.4);
}
That code change the width and may be you want this thing.
Upvotes: 0
Reputation: 68576
(I think) this is what you want..
Change just the style - jsFiddle 1.
$(".class123").closest("td").css('width', '300px');
Or the width itself - jsFiddle 2
$(".class123").closest("td").width('400px');
Upvotes: 2
Reputation: 12916
something like this:
$(".class123").each(function(index, data){
$(this).width("1009034823px"); //Or however large you want it.
});
Have a look at the doc: jquery.width()
PS: The html you provide does not have any TR-elements, so I removed that part.
Upvotes: 0