Nate Pet
Nate Pet

Reputation: 46222

jquery checkboxes checked only

I have a bunch of checkboxes tha start with CheckRR_

I like to loop only for ones that starts with "CheckRR_" and are checked. How would I do this?

I have the following so far:

$('input[name^="CheckRRR_"]').filter(":visible").each(function () { .... 

This works for only the ones that are visible, not checked. I like to look for ones that are checked.

Upvotes: 0

Views: 175

Answers (4)

raina77ow
raina77ow

Reputation: 106385

Try filter(":checked") instead. Or just

$('input[name^="CheckRRR_"] :checked').each(...)

Upvotes: 2

gdoron
gdoron

Reputation: 150253

You can do it with one selector:

$('input[name^="CheckRRR_"]:visible:checked').each(function () {...

If you don't care if they are visible or not:

$('input[name^="CheckRRR_"]:checked').each(function () {...

:checked docs

Upvotes: 0

SLaks
SLaks

Reputation: 887415

$('input[name^="CheckRRR_"]:visible:checked')

Upvotes: 1

Thierry Blais
Thierry Blais

Reputation: 2858

Did you try this yet?

$('input[name^="CheckRRR_"]:checked').each(function () {

Upvotes: 1

Related Questions