I was trying to create a checkbox checked by default for an ecommerce website, I want to show the div when the checkbox is unchecked. and hide the div when the checkbox is checked.
My Fiddle: http://jsfiddle.net/ScnQT/3161/
Answer
You can check whether checkbox is checked using $(this).prop('checked')
if checked $(this).prop('checked') returns true else false
for more details here
Updated fiddle
$('.shipping_address_details').hide();
$('#checkedforShippingAddress').change(function(){
if($(this).prop('checked')){
$('.shipping_address_details').hide();
}else{
$('.shipping_address_details').show();
}
});
No comments:
Post a Comment