I want to replace first Colspan="2" with Colspan="4" in my first TR not in complete page using JQuery.
Thanks.
Best Regards, MS
This jQuery should handle the condition of finding a td with colspan 2 in the first tr of any table and set its colspan to 4.
$("table tr:first td[colspan=2]").attr('colspan',4);
The better thing to do would be to just fix your HTML to produce colspan=4
First of all, you forgot to close one of your <tr>
's. Second, you'll need a unique id or classname attached to that <td>
to target it more easily. Third, use JQuery attr()
method. Like this:
<tr>
<td colspan="2" id="thatsmytd"></td>
</tr>
$('#thatsmytd').attr('colspan','4');
Use :first selector:
$("table tr:first")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With