I have this toggle switch in my JavaScript code:
var questionRequired = document.createElement("div");
questionRequired.className = "mt-1 mb-1";
questionRequired.insertAdjacentHTML(
"beforeend",
`<label class="custom-control ios-switch">
<input type="checkbox" class="ios-switch-control-input" />
<span class="ios-switch-control-indicator"></span>
<span class="ios-switch-control-description">Required</span>
</label>`
);
It is showing nicely and is being turned on and off as we can see here.
My problem is that it's not doing nothing. I want to to set a variable as true if it's turned on and to false when it's turned off.
Let's say I have var isRequired and I wan to set it through this toggle switch. I want to do something like:
if (questionRequired.isTurnedOn)
isRequired = true;
else isRequired = false;
Does anyone kow how I can do this? Thank you.
