Reputation: 719
Hi I want a div to be hidden when the page load and then if a checkbox is checked, show the div and then hide again when it is unchecked.
.checkCover is the checkbox and #show_coversheet is the div.
What is wrong with the below code?
$(function () {
$('.checkCover').change(function () {
$('#show_coversheet').toggle(!this.unchecked);
}).change();
});
Upvotes: 0
Views: 1903
Reputation: 719
Take out the ! before this.checked
$('.checkCover').change(function () {
$('#show_coversheet').toggle(this.checked);
}).change();
Upvotes: 1
Reputation: 104775
unchecked
is not a property, but checked
is!
$('.checkCover').change(function () {
$('#show_coversheet').toggle(!this.checked);
}).change();
Upvotes: 3