I have TRs that are added dynamically after the page is loaded. When they are clicked, I want to add the class “Active” to them. Here is what I have so far:
<tr onClick="makeActive(this);"><td>....</td></tr>
<script>
function makeActive(element){$('.Active').removeClass('Active');element.addClass('Active');}
</script>
The function runs, and removes the “Active” class from any rows that currently have it applied…but it fails to add the class to the clicked row.
Thanks for any help!
thisreferences a DOM element, you have to wrap it inside a jQuery object first to apply a jQuery method to it.