【发布时间】:2016-01-20 23:38:56
【问题描述】:
如何更改 jquery 源,以便我的网站记住用户可能在 24 小时内检查哪个框??
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Show Hide Using Checkboxes</title>
<style type="text/css">
.box{
padding: 20px;
display: none;
margin-top: 20px;
border: 1px solid #000;
}
.red{ background: #ff0000; }
.green{ background: #00ff00; }
.blue{ background: #0000ff; }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input[type="checkbox"]').click(function(){
if($(this).attr("value")=="red"){
$(".red").toggle();
}
if($(this).attr("value")=="green"){
$(".green").toggle();
}
if($(this).attr("value")=="blue"){
$(".blue").toggle();
}
});
});
</script>
</head>
<body>
<div>
<label><input type="checkbox" name="colorCheckbox" value="red"> red</label>
<label><input type="checkbox" name="colorCheckbox" value="green"> green</label>
<label><input type="checkbox" name="colorCheckbox" value="blue"> blue</label>
</div>
<div class="red box">You have selected <strong>red checkbox</strong> so i am here</div>
<div class="green box">You have selected <strong>green checkbox</strong> so i am here</div>
<div class="blue box">You have selected <strong>blue checkbox</strong> so i am here</div>
</body>
</html>
我知道那里有很多,但我认为这个是最简单和最容易的。我已经在我的网站中实现了它。
【问题讨论】:
-
欢迎来到 Stack Overflow。我已经针对一些英语问题调整了您的帖子。请在此处复制并粘贴源代码,而不是链接到它。如果您希望其他人付出努力来帮助您,那么您需要付出努力。
-
你好,这不是我不想粘贴它,我觉得链接上更容易。但它就在这里。 :) 感谢您的编辑
-
彼得,不鼓励仅链接的帖子,属于低质量帖子类别,有些会被删除。既然你已经把它变成了一个高质量的问题,我投了赞成票。
-
我怎样才能修改我的帖子以便其他人可以看到它?
-
有三种方式。 1)使标题更有趣。 2)提供赏金,但您没有足够的代表。 3)希望有超级代表的人给予赏金。我又添加了 2 个标签,这可能会有所帮助。
标签: jquery html cookies show show-hide