我創建了兩個按鈕,其目的是顯示或隱藏段落。但它不會工作,我現在很困惑。顯示和隱藏方法不會在按鈕上工作
HTML代碼:
<!DOCTYPE html>
<html lang="sv-se">
<head>
<meta charset="UTF-8">
<title>My Web Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="show.js"></script>
</head>
<html>
<body>
<p class="para">Click on button to show or hide text</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
這裏是我的javascript代碼:
$(document).ready(function()
$("#hide").click(function(){
$(".para").hide();
});
$("#show").click(function(){
$(".para").show();
});
)};
''$(文件)。就緒(函數()''也許應該是''$(文件)。就緒(函數缺少
{}
( ){''(注意丟失''''''''' –)檢查控制檯總是很好的,如果有任何錯誤的語法,你會看到錯誤信息 –
我明白了,但是我沒有忘記{在我的代碼中只是當我複製代碼在這裏。這種解決方案不適合我... – Waltswen