SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Newbi! JQuery help pls

    folks,

    Code:
    <script language="JavaScript">
    	$(document).ready(function(){
    		$('p#optbox').hide();
    		$('a#showhide').click(function(){
    			$('p#optbox').slideDown('slow');	
    		});
    	});
    </script>
    when i click a#showhide link, the 'p#optbox' is shown.
    now my problem is, when i click again 'p#optbox' should hide.
    how to check the show hide status of an eliment using jquery?

    i did not find a good jquery conditional statement thing when google . so pls help.

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd suggest using toggle, or you could try this:

    Code:
    <script language="JavaScript">
    
      $(document).ready(function(){
    
        $('p#optbox').hide(); // Should use CSS for this
    
        $('a#showhide').click(
          function(){
            if($('p#optbox').is(':visible')){
              $('p#optbox').slideUp('slow');
            }
            else{
              $('p#optbox').slideDown('slow');
            }
          }
        );
    
      });
    </script>
    From the English nation to a US location.

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by awestmoreland View Post
    I'd suggest using toggle, or you could try this:

    Code:
    <script language="JavaScript">
    
      $(document).ready(function(){
    
        $('p#optbox').hide(); // Should use CSS for this
    
        $('a#showhide').click(
          function(){
            if($('p#optbox').is(':visible')){
              $('p#optbox').slideUp('slow');
            }
            else{
              $('p#optbox').slideDown('slow');
            }
          }
        );
    
      });
    </script>
    Fantastic ! the toggle worked for me simply
    Thank you awestmoreland


Bookmarks

Posting Permissions

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