当我选中一个复选框时,我希望能够隐藏整个容器。
* HTML *
<div class="showIt">
<div>abc</div>
<div>123</div>
<div><input type="checkbox" /></div>
</div>
* CSS *
div.showIt {
display:inherit;
}
div.hideIt {
display:none;
}
* JavaScript(它不起作用)*
<script>
jQuery.support.cors = true; // needed for ajax to work in certain older browsers and versions
$(document).ready(function(){
$(this).change(function(e) {
$(this).parent().toggleClass('showIt hideIt');
$(this).closest("div").toggleClass('showIt hideIt');
});
}); // end .ready()
</script>