...

View Full Version : A function to toggle containers



MattClark
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")) {
$('#'+x).slideDown(200);
} else {
$('#'+x).hide();
}
$('interactContainers').hide();
}
</script>




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


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

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

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

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum