【发布时间】:2018-09-25 22:04:26
【问题描述】:
这是我的 html 复选框 --
<input type="checkbox" id="export_1_field_title" value="title">
在 jquery 中,我想检查复选框是否被选中,如果选中则将读取值,所以这是我的查询 --
var title = '';
if($("#export_1_field_title").is("checked"))
{
title = 'title';
}
alert('Here '+title);
但无法阅读复选框,请提出任何需要的更改
【问题讨论】:
-
使用
$("#export_1_field_title").is(":checked")。不要忘记:。 -
你也可以这样使用
if($("#export_1_field_title:checked").length > 0)