标签云

微信群

扫码加入我们

WeChat QR Code

This question already has an answer here:

this is my checkbox

HTML

<label class="checkbox">
    <input id="eu_want_team" name="eu_want_team" type="checkbox">
</label>

JQuery

var eu_want_team = $('#eu_want_team').val();
alert(eu_want_team);

Its always displaying ON, is it checked or not. Whats the problem with it?


Welcome to Stack Overflow. I've re-tagged as jQuery, assuming that's where $() and val() come from. Feel free to correct it if I was wrong. And next time you ask about a non-native JavaScript function don't forget to post its code or mention what library it belongs to.

2018年08月18日36分42秒

u should use .prop('checked') in jQuery

2018年08月18日36分42秒

+1 . Or $("#eu_want_team").prop("checked")

2018年08月18日36分42秒

Itay You're also right. will add to answer

2018年08月19日36分42秒