View Full Version : A function to toggle containers

03-18-2011, 07:59 AM
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:

<script language="javascript" type="text/javascript">
// jQuery functionality for toggling member interaction containers
function toggleInteractContainers(x) {
if($('#'+x).is(":hidden")) {
} else {

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

<?php echo $interactionBox; ?>
<br /><br />
<div class="interactContainers" id="add_friend">
Add as friend container
<div class="interactContainers" id="private_message">
Private message container

someone please help, thanks

03-18-2011, 09:33 AM
can't you use this?


best regards