Replacing Colspan = "2" with Colspan = "4" using jQuery

VenueID: 3                                    

I want to replace the first Colspan = "2" with Colspan = "4" on my first TR not in a full page using jQuery.

Thanks.

Best regards, MS

+5
source share
6 answers

This jQuery should handle the condition of finding 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 best thing would be to simply fix your HTML to create colspan = 4

+15
source

, <tr>. -, , <td>, . -, JQuery attr(). :

<tr>
     <td colspan="2" id="thatsmytd"></td>
</tr>

$('#thatsmytd').attr('colspan','4');
+4

Usage: first selector:

$("table tr:first")
+1
source
$("table tr:first").attr('colspan','4');
0
source
$("table[id$=FormView1] tr:first td[colspan=2]").attr("colspan", "4");
0
source

n1313 The correct decision to change the attribute. If you have a question, how do you select the first line of a page that contains a cell with the colspan attribute, you just need to change the selector to something like this:

$("tr:first").find("td[colspan='2']:first").attr('colspan','4');

This is very specific. You may need to play with it to work just the way you need it.

0
source

All Articles