Reputation: 4056
I create Multiple checkBox under the one div
with data-role="controlgroup"
Now i want to check that after click on specific button which check boxes are checked using JQuery
so what is the best way for do it
Upvotes: 0
Views: 110
Reputation: 4056
Using this you can get all of your checked ckeckboxes
code from here
var selected = new Array();
$('#checkboxes input:checked').each(function() {
selected.push($(this).attr('name'));
});
Upvotes: 0
Reputation: 4177
try like this.
$("div[data-role='controlgroup'] input:checkbox :checked")
Upvotes: 1
Reputation: 10378
use :checked
$("div[data-role='controlgroup'] :checkbox :checked")// by this you get all checked checkbox
Upvotes: 1
Reputation: 5213
Try something like this...
if ($("div[data-role='controlgroup'] input[type='checkbox']").first().prop("checked")) {
// ...
}
That's a pretty hefty selector, and it'll only fetch the first <input type="checkbox" />
that's inside a <div data-role="controlgroup">
. You should tweak it to make it more specific to your project.
In short, jQuery's .prop()
method with "checked"
as the argument will return a Boolean true
or false
depending on whether a checkbox is checked.
Upvotes: 1