admin管理员组文章数量:1244258
How can I make jQuery fire an event when a user checks a checkbox?
<input type="checkbox" id="test" name="test" /><label for="test">Check me</label>
I could do it with .click though that doesn't work when the user tabs to the checkbox. I wasn't able to find info on this in the API docs or while Googling.
How can I make jQuery fire an event when a user checks a checkbox?
<input type="checkbox" id="test" name="test" /><label for="test">Check me</label>
I could do it with .click though that doesn't work when the user tabs to the checkbox. I wasn't able to find info on this in the API docs or while Googling.
Share Improve this question edited Apr 22, 2022 at 7:42 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jun 21, 2010 at 13:54 MauriceMaurice 4,9407 gold badges42 silver badges51 bronze badges2 Answers
Reset to default 12$('#test').bind('change', function(){
if($(this).is(':checked')){
// box was checked
}
});
You're looking for the change
event:
$('#test').change(function() { ... });
本文标签: javascriptjQuery (UI) Detect checking of a checkboxStack Overflow
版权声明:本文标题:javascript - jQuery (UI): Detect checking of a checkbox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740213938a2242518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论