I'm trying to target an element by a class name that I've added to it in jQuery. This seems to work fine if I add a new element, but I can't get the new events to bind to an element that was already in the DOM, but has been changed.
What am I doing wrong?
$(document).ready(function(){
$(".activateRow").on("click",function(){
$(this).text('Deactivate').addClass('deactivateRow btn-danger').removeClass('activateRow btn-success');
$(this).parent().parent().removeClass('inactiveRow');
});
$(".deactivateRow").on("click",function(){
$(this).text('Activate').removeClass('deactivateRow btn-danger').addClass('activateRow btn-success');
$(this).parent().parent().addClass('inactiveRow');
});
})