responsive menu should close when clicked
Dear Sir
the menu works perfectly fine
on PC, Lap Top sand even Mobile
However in case of Mobile (when I view it on Mobile) and click on internal link for navigation e.g. About us
the navigation / scroll happens but menu remsains open
I want the menu close rather collapse and then navigate to the internal link
or
vice a versa
Please help
My Jquery code
- ( function( $ ) {
- $( document ).ready(function() {
- $('#cssmenu').prepend('<div id="indicatorContainer"><div id="pIndicator"><div id="cIndicator"></div></div></div>');
- var activeElement = $('#cssmenu>ul>li:first');
- $('#cssmenu>ul>li').each(function() {
- if ($(this).hasClass('active')) {
- activeElement = $(this);
- }
- });
- var posLeft = activeElement.position().left;
- var elementWidth = activeElement.width();
- posLeft = posLeft + elementWidth/2 -6;
- if (activeElement.hasClass('has-sub')) {
- posLeft -= 6;
- }
- $('#cssmenu #pIndicator').css('left', posLeft);
- var element, leftPos, indicator = $('#cssmenu pIndicator');
- $("#cssmenu>ul>li").hover(function() {
- element = $(this);
- var w = element.width();
- if ($(this).hasClass('has-sub'))
- {
- leftPos = element.position().left + w/2 - 12;
- }
- else {
- leftPos = element.position().left + w/2 - 6;
- }
- $('#cssmenu #pIndicator').css('left', leftPos);
- }
- , function() {
- $('#cssmenu #pIndicator').css('left', posLeft);
- });
- $('#cssmenu>ul').prepend('<li id="menu-button"><a>Menu</a></li>');
- $( "#menu-button" ).click(function(){
- if ($(this).parent().hasClass('open')) {
- $(this).parent().removeClass('open');
- }
- else {
- $(this).parent().addClass('open');
- }
- });
- });
- } )( jQuery );
- /*-------- Code to close menu-----*/
- $('#cssmenu li').on('click', function(){
- $("#cssmenu").hide();
- $("#menu-icon").removeClass("active");
- });
I tried
- $('#cssmenu li').on('click', function(){
- $("#cssmenu").hide();
- $("#menu-icon").removeClass("active");
- });
My html
- <style>
- .smallheading
- {
- font-size:9px;
- }
- </style>
- <header id="header" style="z-index:999" >
- <!--Navigation-->
- <div class="s-1 l-1">
- <a href="index.php" > <img src=images/logonew.png alt="logo" width="185" height="50" role="banner" border="0"></a>
- </div>
-
- <div id='cssmenu' class="s-10 l-10" style="margin-left:0px; padding:0px; " >
- <ul id="popup-menu">
-
- <li><a href="index.php">Home</a></li>
- <li><a href="index21.php#about">About</a></li>
- <li><a href="photographyimages.php?id=140"><span class="smallheading">Wedding </span><br />Photography </a></li>
- <li><a class="scroll" href="index21.php#wedding-film"><span>Wedding </span>Films</a></li>
- <li><a href="photographyimages.php?id=139">Pre-Weddings </a></li>
- <li><a href="corporateevents.php"><span class="smallheading">Corporate</span>Events </a></li>
- <li><a href="#">Services</a>
- <ul>
- <?php $query="select * from photogallery where status=1 order by srno ";
-
- mysql_select_db($database_DBconnect, $DBconnect);
- $Result = mysql_query($query, $DBconnect) or die(mysql_error());
- $rows = mysql_fetch_assoc($Result);
- $totalrows=mysql_num_rows($Result);
- do {
- ?>
- <li><a href="photographyimages.php?id=<?php echo $rows['id'];?>">
- <?php echo $rows['name'];?> </a>
- </li>
- <?php } while($rows = mysql_fetch_assoc($Result));
-
- ?>
- </ul>
- </li>
- <!-- <li><a href="testimonial.php">Testimonials</a></li> -->
- <li><a class="scroll" href="index21.php#contact">Contact</a></li>
- <li><a href="freelancer.php" target="_self"><span>For</span> Freelancer</a></li>
-
- </ul>
- </div>
-
- <!--/ Navigation-->
- </header>