使用jquery获得所有选中的复选框和一个特定的类名 [英] Using jquery to get all checked checkboxes with a certain class name
本文介绍了使用jquery获得所有选中的复选框和一个特定的类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$('input [type = checkbox] ').each(function(){
var sThisVal =(this.checked?$(this).val():);
}
但是我现在在一个页面上使用这个,有一些其他的复选框,我不想包括。
解决方案
<$ c $如何修改上面的代码, c> $('。theClass:checkbox:checked')会给你所有选中的复选框类 theClass
。
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')
will give you all the checked checkboxes with the class theClass
.
这篇关于使用jquery获得所有选中的复选框和一个特定的类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文