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
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question click function not working

    I am coding a site and using jquery for effects. I am trying to run this code -
    Code:
    $(document).ready(function(){
    						$("#eventbar").hide();
    					});
    					
    					$(".nav_events").click(function(){
    						$("#eventbar").toggle("slow");
    					});
    it hides it, but clicking does the div with that class does not show it. Am i doing something wrong?

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,474
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Yes, you need to move the code related to the click function inside the document ready function because otherwise that code is evaluated/executed before the DOM has loaded (unless you insert the script at the end of the page which I assume you haven’t because in that case you wouldn’t need any document ready function at all) and the element you are trying to address doesn’t yet exist at that time.

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this isn't working, but part of me is saying that i misinterpreted what you are saying
    Code:
    	$(document).ready(function(){
    						$("#eventbar").hide();
    						$(".nav_events").click(function(){
    							$("#eventbar").toggle("slow");
    						});
    					});

  • #4
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    never mind, ignore me, I went full retard and was loading the wrong file.


  •  

    Posting Permissions

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