html
<div class="btn-group" data-toggle="buttons-checkbox">
<label class="btn" for="id_bar">
<input type="checkbox" name="bar" value="1" id="id_bar" />
Bar
</label>
<label class="btn" for="id_open">
<input type="checkbox" name="open" value="1" id="id_open" />
Open now
</label>
</div>
script
var searchForm = $('.main-search-form');
var labels = $(searchForm).find('label');
try {
$(labels).on({
click: function () {
var item = $(this).children('input[type=checkbox]').parent();
$(item).addClass('active');
alert('test');
}
});
} catch (e) {
alert(e);
}
doubt
i am using twitter bootstrap. when label is clicked , obviously test text pops up as alert , during that time label has the class active but as soon as i close the alert box , label class active vanishes , please help
i figured that out ,
just removed the attribute data-toggle , and its all fine now
but again the toggleClass method is not working ,