Onchange event on checkbox always shows this.value = on
The input checkbox of type type when the event is triggered is onchange
this.value
always set to on
, even if the checkbox is checked, in which case I expect it to beoff
Is this the intended behavior?
short answer: don't use value
to check the check on checkbox, use checked
instead
and in case you are wondering why this value is always "on", there is a spec for the HTML5 spec:
default / on
On getting, if an element has a value attribute, it must return that attribute value; otherwise, it should return the string "on" . On customization, it should set the element's value attribute to a new value.
http://www.w3.org/TR/html5/forms.html#dom-input-value-default-on