I have a checkbox inside a div which has a click event attached to it. But the checking and unchecking the checkbox directly doesn't work.
<div class="container" onclick="select(this)">
<input type="checkbox" value="" /><label>Item</label>
</div>
function select(e) {
var elm = $(e);
var chkBox = elm.find('input');
console.log(chkBox.is(':checked'));
if(chkBox.is(':checked')) {
chkBox.prop("checked", false);
}else{
chkBox.prop("checked", true);
}
}
Demo : http://jsfiddle.net/h45A5/