checkbox problem
by julienkindle
HTML
<div class="box">
<div class="something">
<input type="checkbox" class="checkbox" />
</div>
</div>
<div class="box">
<input type="checkbox" class="checkbox" />
</div>
<div class="box">
<input type="checkbox" class="checkbox" />
</div>
CSS
.box{
width:100px;
height:100px;
background-color:red;
margin-bottom:10px;
text-align:center;
line-height:100px;
vertical-align:middle;
}
JavaScript
$(function() {
$(".box").click(function(event) {
// alert(event.target.tagName);
if(event.target.className != 'box') return;
var objCheckbox = $(this).find("input[type=checkbox]");
if( objCheckbox.length >= 1 ) {
objCheckbox.prop("checked", !objCheckbox.prop("checked"));
}
});
});