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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    120
    Thanks
    6
    Thanked 2 Times in 2 Posts

    A function to toggle containers

    I have two buttons, and use jquery for when they're clicked i have a drop down area. It works except for when I click one, it doesn't make the other one go back up. There will just be two areas now. I want the 2nd one to make the 1st one close if the first one is open.

    Anyways, here is my code:

    Code:
    <script language="javascript" type="text/javascript">
    // jQuery functionality for toggling member interaction containers
    function toggleInteractContainers(x) {
    	if($('#'+x).is(":hidden")) {
    	$('#'+x).slideDown(200);
    } else {
    	$('#'+x).hide();
    	}
    	$('interactContainers').hide();
    }
    </script>
    Code:
    $interactionBox = '<div class= "interactionLinksDiv">
    <a href="#" onclick = "return false" onmousedown="javascript:toggleInteractContainers(\'add_friend\');">Add as friend</a>
    <a href="#" onclick = "return false" onmousedown="javascript:toggleInteractContainers(\'private_message\');">Message</a>
    </div>';
    Code:
     <?php echo $interactionBox; ?>
    				<br /><br />
    				<div class="interactContainers" id="add_friend">
    				Add as friend container
    				</div>
    				<div class="interactContainers" id="private_message">
    				Private message container
    				</div>
    someone please help, thanks

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    can't you use this?

    http://api.jquery.com/slideToggle/

    best regards


  •  

    Posting Permissions

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