我確定這是處理javascript時的常見問題,但我似乎無法找到解決方案。無法與課堂變化後的元素交互
我試圖在「卡」上創建兩個函數,但是通過卡的狀態類來區分。
「啓動」卡和「刪除」卡的功能之一。但是當我啓動一張卡時,Im無法使用相同的功能將其刪除。
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();
});