Toggle checkbox by description
Posted on July 16, 2013
This code toggle’s the checkbox value by clicking on the description. The code is useable for all checkboxes on your website.
CSS
.chkBoxTxt{
cursor:pointer;
}
input[type="checkbox"]{
width: 13px;
height: 13px;
padding: 0;
margin:0;
vertical-align: bottom;
position: relative;
top: -1px;
*overflow: hidden;
}
HTML
Agree with terms
Jquery
$(document).ready(function(){
$('.chkBoxTxt').click(function(){
var checkBox = $(this).parent().find('input[type="checkbox"]');
checkBox.prop("checked", !checkBox.prop("checked"));
});
});