What value will the variable checked
have if the checkbox is checked? What is its value if the checkbox is unchecked?
HTML:
<input type="checkbox" id="my_id" />
jQuery:
var checked = $('input#my_id').is(':checked');
What value will the variable checked
have if the checkbox is checked? What is its value if the checkbox is unchecked?
HTML:
<input type="checkbox" id="my_id" />
jQuery:
var checked = $('input#my_id').is(':checked');
I recommend you use console.log()
or any way you like to check the values, but I've made an example here.
The value will be true
or false
From the jQuery documentation for is
.
Checks the current selection against an expression and returns true, if at least one element of the selection fits the given expression.
If no element fits, or the expression is not valid, then the response will be 'false'.
So you can be sure the answer will either be true
or false
.