jQuery 移动导航栏错误
jQuery Errors for mobile Nav Bar
我对 jQuery 还不是很了解,但是当单击菜单按钮时,我正在使用它使此导航菜单下拉用于 phone 大小的媒体查询。我一直收到这个我无法弄清楚的错误。
未捕获的 ReferenceError:未定义 toggleMenu meetPractioner.html:53 onclick
我使用的脚本是这样的:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
function toggleMenu() {
$('nav ul li a').slideToggle("fast");
}
</script>
而 html 是:
<nav>
<ul>
<li><a href="meetPractioner.html">Meet The Practioner</a></li>
<li><a href="servicesRates.html">Services & Rates</a></li>
<li><a href="bookAppointment.html">Book Appointment</a></li>
<li><a href="locationHours.html">Location & Hours</a></li>
<li><a href="testimonials.html">Testimonials</a></li>
<li><a href="questions.html">Questions & Answers</a></li>
<li><a href="benefits.html">Benefits of Massage</a></li>
<li><a href="bodySense.html">Body Sense Magazine</a></li>
</ul>
<a onclick="toggleMenu()" class="menu-bttn">Menu</a>
</nav>
我的 jsFiddle 是 http://jsfiddle.net/Floyd/v723oqfc/1/
非常感谢任何帮助。
在您的 fiddle 中,您没有定义 toggleMenu。
但请在您的文档 <head>
中尝试以下内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function toggleMenu() {
$('nav ul li a').slideToggle("fast");
}
</script>
这应该可以解决您的问题。
编辑
Fiddle:http://jsfiddle.net/v723oqfc/2/(注意框架和扩展中的 "No wrap - in <head>
")
我对 jQuery 还不是很了解,但是当单击菜单按钮时,我正在使用它使此导航菜单下拉用于 phone 大小的媒体查询。我一直收到这个我无法弄清楚的错误。
未捕获的 ReferenceError:未定义 toggleMenu meetPractioner.html:53 onclick
我使用的脚本是这样的:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
function toggleMenu() {
$('nav ul li a').slideToggle("fast");
}
</script>
而 html 是:
<nav>
<ul>
<li><a href="meetPractioner.html">Meet The Practioner</a></li>
<li><a href="servicesRates.html">Services & Rates</a></li>
<li><a href="bookAppointment.html">Book Appointment</a></li>
<li><a href="locationHours.html">Location & Hours</a></li>
<li><a href="testimonials.html">Testimonials</a></li>
<li><a href="questions.html">Questions & Answers</a></li>
<li><a href="benefits.html">Benefits of Massage</a></li>
<li><a href="bodySense.html">Body Sense Magazine</a></li>
</ul>
<a onclick="toggleMenu()" class="menu-bttn">Menu</a>
</nav>
我的 jsFiddle 是 http://jsfiddle.net/Floyd/v723oqfc/1/
非常感谢任何帮助。
在您的 fiddle 中,您没有定义 toggleMenu。
但请在您的文档 <head>
中尝试以下内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function toggleMenu() {
$('nav ul li a').slideToggle("fast");
}
</script>
这应该可以解决您的问题。
编辑
Fiddle:http://jsfiddle.net/v723oqfc/2/(注意框架和扩展中的 "No wrap - in <head>
")