HTML复选框的价值

时间:2015-03-04 20:46:48

标签: javascript jquery html

我无法检查html表单中复选框的值。这是html

<input type="checkbox" name="terms" id="termcheck"> I Agree to the<a target="_blank" href="">Terms of Service.</a>

这是我的js

$("#submit_btn").on("click", function(event){
    event.preventDefault();
    alert($("#termcheck").checked)
});

每次都给我“未定义”。我只是希望能够看到盒子是否已被检查过。

1 个答案:

答案 0 :(得分:0)

试试这个:

$("#submit_btn").on("click", function(event){
event.preventDefault();
alert($("#termcheck")[0].checked)
});

检查这个JSFiddle http://jsfiddle.net/5cxcL2wp/4/