Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question Click to show menu not working

    hi, on my site in MOBILE view: Here


    Jquery
    Code:
    	<script type="text/javascript">
    
    
    
    $(function(){
    
    	$(".menulink span").show();
    	var clickCount=0;
         $(".menulink span").click(function(){
         
         	if(clickCount%2==0){
         		$(".topnav").show();
         		$(this).text('Hide Menu');
         	} else {	
         		
            	$(".topnav").hide();
            	$(this).text('Show Menu');
          	}
          	clickCount++;
          });
    });
    
    
    
    </script>
    my HTML
    Code:
    <div class="menulink">
    					<span>Show Menu</span>
    				</div>
    				<div class="topnav">
    					<ul>
    <li><a href="linky"></li>
    </ul>
    				</div>

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    maybe try this
    Code:
    	<script type="text/javascript">
    
    
    
    $(function(){
    
    	$(".menulink span").show();
    	var clickCount=0;
         $(".menulink span").on('click',function(){
         
         	if(clickCount%2==0){
         		$(".topnav").show();
         		$(this).text('Hide Menu');
         	} else {	
         		
            	$(".topnav").hide();
            	$(this).text('Show Menu');
          	}
          	clickCount++;
          });
    });
    
    
    
    </script>

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    thanks but that didn't work

  • #4
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    The problem, surely, is that .menulink is hidden by your css.

    I think there's a missing bit of script that shows .menulink and hides .topnav.
    Use the W3C HTML Validator and CSS Validator to check your code and Firebug to see what css is applied to an element
    Read Steve Krug's book Don't Make Me Think - essential reading on web usability
    I don't recommend much, but I do recommend Clook for UK web hosting


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •