Tye Lucas Tye Lucas - 4 months ago 8
jQuery Question

How to remove an element from a <tr>

Here is the code:

<tr class="active" aria-selected="true" data-row-id="3">


I am using: $("tr").removeClass("active"); to remove the "active" class which works perfectly but I also need to set aria-selected="true" to "false", this is for a data-table selection in a modal. Any help will be most helpful,

Thank you!

Answer

Use jQuery attr() method to update element attribute.

$('tr').attr('aria-selected','false');
Comments