diff --git a/js/index.mjs b/js/index.mjs index 235a013..7c97e13 100644 --- a/js/index.mjs +++ b/js/index.mjs @@ -32,9 +32,14 @@ function handle_mutation_word_keyup(event) { const el_mutations = document.querySelector("#mutations"); const el_step = event.target.closest(".mutation-step"); const el_word = event.target.closest(".mutation-option"); + const els_word = el_step.querySelectorAll(".mutation-option"); + + // 2: Update UI - Change classes, Remove all subsequent mutation steps + for(let i = 0; i < els_word.length; i++) + els_word[i].classList.remove("selected"); - // 2: Update UI - Add classes, Remove all subsequent mutation steps el_word.classList.add("selected"); + while(el_step.nextElementSibling !== null) el_step.parentNode.removeChild(el_step.nextElementSibling);