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 Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question jQuery Toggle Help

    Ok i have this code

    Code:
    <script src="jquery-1.3.2.js" type="text/javascript" /></script>
              <script type="text/javascript">
                   $(document).ready(function(){
    										  
                       $('#popuptoggle').click(function(){
                            $('#popupbg').toggle('slow');
                       });
    				   
    				   $('#popuptoggle').click(function(){
                            $('#popup').toggle('slow');;
                       });
    				   
                  });
              </script>
    now i want the divs with the id popup and popupbg to be hidden when the page is first loaded so i tried this

    Code:
     $("#popupbg").hide();
    					
    $("#popup").hide();
    and it worked but they dont toggle hide/show.

    also can i get the div to be hidden right when the page loads because right now its there until the page loads then it hides
    SkyePHP | Head Developer & Project Manager.
    Release: TBA
    Like the Facebook Page for Updates!

  • #2
    New Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will also mention that the divs are in a file(video.php) that is included in index.php via a switch statement. and the jQuery code is between the <head> and </head> tags in index.php

    Index.php ----Switch Statement---> video.php
    |
    jQuery Code
    SkyePHP | Head Developer & Project Manager.
    Release: TBA
    Like the Facebook Page for Updates!

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    171
    Thanks
    13
    Thanked 1 Time in 1 Post
    Try using
    display:none;
    in the css for the divisions you wish to be hidden.

    Andy

  • #4
    New Coder
    Join Date
    Feb 2009
    Location
    Uzbekistan
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    1andyw's solution is the best way to go.

    Also, I would also like to point out that if you'd put your div hiding code into the document ready it would have worked as well. Just pointing it out so that others don't get confused.

    Code:
    $(document).ready(function(){
      $("#popupbg").hide();
      $("#popup").hide();
    });


  •  

    Posting Permissions

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