Im sure this is common problem when dealing with javascript, but I can't seem to find a solution for it.
Im trying to create two functions on a "card", but differentiated by a class of the state of the card.
One function to "start" the card and one function to "remove" the card. But when I start a card, Im not able to remove it with the same function.
html
<div class="card started">click to hide</div>
<div class="card not-started">click to start</div>
js
$(".card.not-started").on("click", function () {
$(this).removeClass("not-started").addClass("started").html("click to hide");
});
$('.card.started').on("click", function () {
$(this).fadeOut();
});