metaforce
metaforce

Reputation: 1377

Check if more than one checkbox is selected in jQuery

I need to know if more than one checkbox is selected from my list.

How to achive this using jQuery?

I've tried something with :checked, but no success.

Thanks all for help!

Upvotes: 2

Views: 11081

Answers (2)

Farshid Zaker
Farshid Zaker

Reputation: 1990

var n = $("input:checked").length;
if (n >= 2)
   ...

Upvotes: 4

rahul
rahul

Reputation: 187040

Assuming your container will have an id

if ($("#containerID input:checkbox:checked").length > 1) {
   // your code goes here
}

See a working demo

Upvotes: 11

Related Questions