<html>
<head>
<title>RateUs</title>
<link rel="stylesheet" type="text/css" href="css\slide.css">
<script type="text/javascript" src="js/hamburgerMenu.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div class="menu">
<button class="hamburger">☰</button>
<button class="cross">˟</button>
<?php
$Title = "";
$Description = "Say Hello to Web, cause we will make the expierience like never before From our Web Devolopment and SEO services. Way to Go!"
?>
<ul>
<a href="#"><li>LINK ONE</li></a>
<a href="#"><li>LINK TWO</li></a>
<a href="#"><li>LINK THREE</li></a>
<a href="#"><li>LINK FOUR</li></a>
<a href="#"><li>LINK FIVE</li></a>
</ul>
</div>
</head>
</style>
<body>
<h1><?php echo $Title ?></h1>
<div class="container">
<div class="slideImage">
<img src="http://images.locanto.net/1650267478/Ultimez-Technology-Popular-Web-Design-Company-in-Bangalore_2.jpg" title="Long Arrow Left">
</div>
</div>
<p><?php echo $Description ?></p>
</body>
</html>
这是html代码,js代码低于......
$( ".cross" ).hide();
$( ".menu" ).hide();
$( ".hamburger" ).click(function() {
$( ".menu" ).slideToggle( "slow", function() {
$( ".hamburger" ).hide();
$( ".cross" ).show();
});
});
$( ".cross" ).click(function() {
$( ".menu" ).slideToggle( "slow", function() {
$( ".cross" ).hide();
$( ".hamburger" ).show();
});
});
现在问题是它始终说“ReferenceError:$未定义”,我也添加了
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
两个jquery链接库都没有工作仍然得到相同的错误请帮助,这是一个汉堡菜单代码,我从https://www.codecademy.com/en/courses/web-beginner-en-seyrq/0/1?content_from=make-an-interactive-website%3Ajquery-effects codepen采取所以请帮助我是一个新手PLZ做
答案 0 :(得分:2)
更改脚本的顺序。
hamburgerMenu.js
引用了jquery。解析时,它将查找jquery对象,但jQuery尚未加载,因为它在加载序列中排在第二位。
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/hamburgerMenu.js"></script>
另外,为了加快页面加载速度,您可以在body
标记
<body>
//rest of code
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/hamburgerMenu.js"></script>
</body>