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