Skip to content Skip to sidebar Skip to footer

Bootstrap Check/uncheck Multiple Elements With Js

I am trying to make this work but can't make it happen. I have a bootstrap template and i want to check and uncheck multiple checkboxes (like this: http://jsfiddle.net/v6wmV/177/ )

Solution 1:

you need to go up two stages instead of one. parent() gives you the label element, you need to go up to the "controls"-classed div to apply your find method :

var $checkboxes = $(this).parent().parent().find('input[type=checkbox]');

Of course that was to apply minimal change to your code way. The one provided by Joe up here is probably smarter : getting all the checkboxes you want without having to use parent() method. But to do so you might want to id your checkbox group so that you do not select all the checkboxes accross your DOM.

By the way, don't you have to show your hide div at some point to see your checkboxes ?

Edit> OK actually Manish is right with parents it is just right, forget my answer :D

Post a Comment for "Bootstrap Check/uncheck Multiple Elements With Js"