首先,我的脚本允许我使用复选框来交换div。
JS小提琴示例:http://jsfiddle.net/yHTFF/8/
我正在寻求帮助设置正确的cookie为这个脚本。我想对其进行设置,以便用户保留的div和复选框在页面重新加载时保持不变。
下面是我的脚本:
<!--HTML-->
<div id="ontopic_posts">
Content 1
</div>
<div id="offtopic_posts" style="display: none;">
Content 2
</div>
<input id="cbox_posts" type="checkbox"> show off-topics
<!--JQUERY-->
<script>
jQuery("#cbox_posts").click(function() {
if ( jQuery(this).is(':checked') )
{
jQuery("#offtopic_posts").show();
jQuery("#ontopic_posts").hide();
}
else
{
jQuery("#offtopic_posts").hide();
jQuery("#ontopic_posts").show();
}
});
</script>
谢谢!
发布于 2011-05-28 19:45:06
在元素存在之前附加事件处理程序。
在输入后移动script
标记或使用$(document).ready
.包装脚本
https://stackoverflow.com/questions/6161360
复制相似问题