【发布时间】:2016-03-16 11:23:30
【问题描述】:
我有一个复选框。我在复选框下有一个包含内容的 div。当复选框被选中时,div 被隐藏。当复选框未选中时,div 可见。
加载页面时,我希望选中复选框并隐藏 div。当复选框未选中时,div 应该是可见的。
我尝试过使用点击功能,也尝试过使用显示和隐藏。但我无法得到代码来做我想做的事。非常感谢任何帮助。
这是我的代码:
<script>
$(document).ready(function()
{
$('#checkbox_content').change(function()
{
if(this.checked)
$('#content').fadeOut('slow');
else
$('#content').fadeIn('slow');
});
});
</script>
<div>
<form action="">
<input type="checkbox" name="" value="" id="checkbox_content" checked="checked">
</form>
</div>
<div id="content">
div content here
</div>
【问题讨论】:
标签: javascript checkbox