<table border="1">
<tr><td>111</td><td>22</td><td rowspan="3">ads</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
<tr><td>111</td><td>22</td><td rowspan="3">ads</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
<tr><td>111</td><td>22</td><td rowspan="3">ads</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
<tr><td>111</td><td class="remove">22</td></tr>
</table>
$('.remove').click(function(){
$(this).parent().remove();
})
FIDDLE: http://jsfiddle.net/r5BDW/1/
If I remove TR then table is breaks because ROWSPAN is too large. Is possible modify ROWSPAN? If yes, how?
$('.remove').click(function(){
$(this).parent()
.prevAll('tr:has(td[rowspan]):first')
.find('td[rowspan]')
.attr('rowspan', function(i, rs) { return rs - 1; })
.end()
.end()
.remove();
});
.parent()
.prevAll()
element-selector
has-selector
has-attribute-selector
first-selector
.find()
.attr()
.end()
.remove()
I would expect the attr() method to work... try this:
$('selector for the element you want to modify').attr('rowspan', 'newvalue');
For example:
$('#myCell').attr('rowspan', '2');
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