I want merge the all td where classname=’blahblah’
Here is my Html Code:
<table><tbody><tr>
<th>Single Room</th>
<th>101</th>
<td class="blahblah"></td>
<td class="blahblah"></td>
<td class="blahblah"></td>
<td></td>
<td></td>
</tr>
<tr>
<th>Single Room</th>
<th>102</th>
<td class="blahblah"></td>
<td class="blahblah"></td>
<td class="blahblah"></td>
<td></td>
<td></td>
</tr></tbody></table>
this is my jquery that i am using to put the text in one td.
Please let me know how can i do this
$(“tbody”).find(“tr”).each(function() {
//merge and put the text to All merged TD's
$(this).find('td.blahblah').text('hi');
});
Please help me how we can do this.
Assuming I’ve understood what you’re trying to do correctly, you can get all the
td.blahblahelements, remove all but the first (seenot,:firstandremove) and then set the text in the one left:Here’s a working example.