1
我无法隐藏和显示p标记。有人可以帮我解决这个问题。我在尝试完成的是 ,当您单击隐藏按钮时,内容被隐藏。然后,当您准备好显示内容时,请点击显示按钮。我知道你可以使用切换,但我不想这样做,使用jquery显示/隐藏
<!DOCTYPE html> <!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(value){
$("button").click(function(value){
if (value==="hide"){
$("p").hide();}
else
$("p").show();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button value="hide">Hide me</button>
<button value="show">Show me</button>
</body>
</html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(value){
$("button").click(function(value){
if (value==="hide"){
$("p").hide();}
else
$("p").show();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button value="hide">Hide me</button>
<button value="show">Show me</button>
</body>
</html>
你不能有多个` ID的同名。改为使用`class` es。 – 2010-12-09 20:55:29
@patrick - 非唯一ID是无效的HTML标记。 – 2010-12-09 20:58:02