Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
checked如果选中复选框,变量将具有什么值?如果未选中复选框,它的值是多少?
checked
HTML:
<input type="checkbox" id="my_id" />
jQuery:
var checked = $('input#my_id').is(':checked');
我建议您使用console.log()或任何您喜欢的方式来检查这些值,但我在这里做了一个示例。
console.log()
该值将是true或false
true
false
来自. _is
is
根据表达式检查当前选择,如果选择的至少一个元素适合给定的表达式,则返回 true。 如果没有元素适合,或者表达式无效,则响应将为“假”。
根据表达式检查当前选择,如果选择的至少一个元素适合给定的表达式,则返回 true。
如果没有元素适合,或者表达式无效,则响应将为“假”。
因此,您可以确定答案将是true或false。