使用 jquery 获取具有特定类名的所有选中的复选框 [英] Using jquery to get all checked checkboxes with a certain class name

查看:16
本文介绍了使用 jquery 获取具有特定类名的所有选中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用此方法获取页面上所有选中的复选框:

I know I can get all checked checkboxes on a page using this:

$('input[type=checkbox]').each(function () {
    var sThisVal = (this.checked ? $(this).val() : "");
});

但我现在在一个页面上使用它,该页面有一些我不想包含的其他复选框.我将如何更改上述代码以仅查看具有特定类的已选中复选框?

But I am now using this on a page that has some other checkboxes that I don't want to include. How would I change the above code to only look at checked checkboxes that have a certain class on them?

推荐答案

$('.theClass:checkbox:checked') 会给你所有选中的复选框与类 theClass.

$('.theClass:checkbox:checked') will give you all the checked checkboxes with the class theClass.

这篇关于使用 jquery 获取具有特定类名的所有选中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆