I have below sample table code,
<table id="Table1">
<thead>
<th>Title</th>
</thead>
<tbody>
<tr>
<td>Row 1</td>
</tr>
<tr>
<td>Row 2</td>
</tr>
<tr>
<td>Row 3</td>
</tr>
<tr class='disabled'>
<td>Row 4</td>
</tr>
<tr>
<td>Row 5</td>
</tr>
</tbody>
</table>
I'm applying below jQuery Sortable, which works fine,
$("#Table1 tbody").sortable({
});
But, now I want to exclude sortable for "tr" having class "disabled", to do I'm applying below code (the jquery selector), but it DOESN't work. Is there anything wrong with selector? I have to use "thead" and "tbody" in HTML table.
Or is there any alternative approach? Thanks,
$("#Table1 tbody tr:not(.disabled)").sortable({
});
Use the items
option:
Specify which items are eligible to sort by passing a jQuery selector into the items option. Items excluded from this option are not sortable, nor are they valid targets for sortable items.
$("#Table1 tbody").sortable({
items: 'tr:not(.disabled)'
});
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