Say that I have an input with the type "checkbox"
<input type='checkbox' id='checker'>
I need to be able to detect instantly whether this box is checked, without a button click or function call. Checking and unchecking the box will lighten or darken text. How do I constantly check whether the box is unchecked or not IN VANILLA JAVASCRIPT? I need to be able to do this, preferably without an infinite for-loop that'll crash the page. I know the method for it
var value=document.getElementById('checker').checked;
but I need a way to constantly see whether it has been checked or not without reloading the page using vanilla javascript. Please help!
EDIT: I am also considering using two radio buttons, one with value true and the other with value false, but I still need a way of seeing which one is checked.
Aucun commentaire:
Enregistrer un commentaire