這裏是第一次程序員。我正在嘗試添加到我正在構建的某個網站中,並且遇到了一些jQuery問題。我用我的代碼找不到問題,但是當我點擊相關的鏈接時,它唯一做的就是在URL的末尾添加一個#。我在這裏錯過了什麼?非功能性JavaScript
謝謝。代碼如下。
的JavaScript:
$(document).ready(function(){
$('.ShowHideButton').click(function(){
$('.MenuBar').slideToggle('slow');
});
});
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="NavMenu.js"></script>
<link type="text/css" rel="stylesheet" href="common.css">
<title>Test Room, North Wall</title>
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="shortcut icon" href="Icons/Favicon.PNG" type="image/x-icon" />
</head>
<div class="Wall">
<img src="Rooms/NorthBlank.JPG" width = 100% />
</div>
<div class="Tray">
<div class="SlideBar">
<div class="ShowHideButton">
<a href = "#"><img src="Icons/Toggle.png" /></a>
</div>
</div>
<div class="MenuBar">
<ul>
<li><a href = "TestWest.htm"><img src="Icons/NavLeft.png" /></a></li>
<li><img src="Icons/Info.PNG" /></li>
<li><a href = "TestDoor.htm"><img src="Icons/Door.PNG" /></a></li>
<li><a href = "TestEast.htm"><img src="Icons/NavRight.png" /></a></li>
</ul>
</div>
</div>
</body>
</html>
CSS:
head{
font-family: Tahoma;
}
body {
font-family: Tahoma;
background-color: Black;
margin: 0px;
padding: 0px;
}
li {
display: inline;
}
.Wall {
margin: 0px;
padding: 0px;
border: none;
position: fixed;
top: 0px;
left: 0px;
}
.Tray {
width: 100%;
height: 150 px;
position: fixed;
bottom: 0px;
}
.MenuBar {
height: 150px;
width: 600px;
bottom: 0px;
margin-bottom: 0px;
margin-left: auto;
margin-right: auto;
background-color: #999999;
opacity: 0.6;
}
.SlideBar {
width: 100%;
height: 150 px;
position: relative;
bottom: 0px;
}
.ShowHideButton {
height: 16px;
width: 90px;
margin-left: auto;
margin-right: auto;
background-color: #999999;
opacity: 0.6;
}
除了缺少jQuery庫之外,我還建議您學習如何在瀏覽器中進行調試(最好是Chrome或Firefox的firebug)。 – ShadowScripter 2013-05-13 13:06:18
@ShadowScripter--很好的建議;不確定在這種情況下會有所幫助。 – 2013-05-13 13:08:43