Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Aaron Endsley
Courses Plus Student 17,625 PointsResponsive Jquery Nav issues
I am building a site for a client and I have the majority of it done the nav on the desktop layout works but the nav on the mobile view selects the contact page no matter what link you click.
This is my html code
<div class="deco">
<div class="menu_container">
<div class="center_menu"><div class="logo"><img src="Images/Logo/logo_desktop copy.png"></div>
<nav class="mobile"><ul>
<li><a href="index.html">Home</a></li>
<li><a href="capabilities.html">Capabilities</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="contact.html">Contact</a></li>
</ul></nav>
</div></div>
</div>
<header>
<img src="Images/Logo/logo_desktop copy.png" class="logo-mobile">
<div id="openMenu"><img src="Images/menu.png" class="menuPic"></div>
</header>
<div class="mobile_menu">
<div id="closeMenu"><img src="Images/menu.png" class="menuPic"></div>
<nav class="mobile"><ul>
<li><a href="index.html">Home</a></li>
<li><a href="capabilities.html">Capabilities</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="contact.html">Contact</a></li>
</ul></nav>
</div>
and this is my javascript code
$('nav').hide();
var $menu=$('.mobile');
$('#closeMenu').hide();
$( "#openMenu" ).click(function() {
$menu.slideToggle( "slow", function() {
$('header').hide();
$('#closeMenu').show();
})
});
$( "#closeMenu" ).click(function() {
$('header').show();
$('#openMenu').show();
$('#closeMenu').hide();
$menu.slideToggle( "slow", function() {
})
});
4 Answers
Jonty Ward
1,982 PointsHi Aaron Endsley - can you duplicate your markup in a jsfiddle so we can take a proper look and fix this.
Aaron Endsley
Courses Plus Student 17,625 PointsAH HA!!! fixed it with a little bit of tinkering.
Aaron Endsley
Courses Plus Student 17,625 PointsUnfortunately, i have never used jsfiddle lol..... although i did just sign up for an account, i have site hosted on our testing server..would it be okay if i post that link
Aaron Endsley
Courses Plus Student 17,625 Pointsalso i unfortunately ended up designing for desktop first...because the client is more concerned about desktop than mobile =( so please forgive the messy css