Newbi! JQuery help pls

folks,

<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.

I’d suggest using toggle, or you could try this:

<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 :slight_smile:
Thank you awestmoreland :slight_smile: