I am trying to redesign a quiz template that only allows users to choose one answer before the other options are disabled. The user should be able to choose another answer (erasing the first) before submitting.
I can remove the highlighted color class if a new answer is chosen:
answer.classList.remove("correct");
How do I remove the element for the 'tick' icon:
let tickIconTag = '<div class="icon tick"><i class="fas fa-check"></i></div>';
from this parent element:
'<div class="option"><span>'+ multiple_choice_option[i] +'</span></div>'
when the option is set like this:
const option = option_list.querySelectorAll(".option");
for(i=0; i < option.length; i++)
{
option[i].setAttribute("onclick", "optionSelected(this);");
}//end for
and the tickIconTag is added like this:
answer.insertAdjacentHTML("beforeend",tickIconTag);
I have tried multiple ways but the main issue is that:
1.Using answer.insertAdjacentHTML("beforeend", blankelement) shifts tick inward not removed
2.Using tickIconTag.remove() gives the error "tickIconTag.remove is not a function"
3.Using answer.removeChild(tickIconTag) give the error "Parameter 1 is not of type node".
How can I set precisely the same element to blank and not shift it or remove it?
This is an image of what happens when I try to replace the element with a blank one. Green tick shifted but not removed