最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Check if more than one checkbox is selected in jQuery - Stack Overflow

programmeradmin3浏览0评论

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!

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!

Share Improve this question edited Jun 3, 2011 at 7:45 Reporter 3,9485 gold badges35 silver badges49 bronze badges asked Jun 3, 2011 at 7:42 metaforcemetaforce 1,3775 gold badges17 silver badges26 bronze badges 2
  • Does selected mean checked? Can you post the relevant parts of your markup, and the code you have so far? – Frédéric Hamidi Commented Jun 3, 2011 at 7:45
  • Please post your html and javascript source code. For help we have to take look on it. – Reporter Commented Jun 3, 2011 at 7:46
Add a ment  | 

2 Answers 2

Reset to default 11

Assuming your container will have an id

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

See a working demo

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

评论列表(0)

  1. 暂无评论