[SOLVED w/ Scriptaculous]
Hey everyone, Im just kicking off with jQuery but I think I got myself in a dilemma. I hope someone can understand what I am trying to accomplish and can help.
I have several buttons and each button has a div which contains additional information. The Divs are hidden until you click on the button.
The button needs to test 1) to see if any other divs are open, if so close them and 2) it needs to open the div specific to itself. The divs must close before the new div is opened. In other words there is only ever 1 div open and must close before any another div is being opened.
Due to the naming of the divs, and working in someone elses code, I am unable to come up with an if statement that works.
Here is the jQuery I am working with right now, but need the slideUp functions to trigger before the slideDown function.
<script type="text/javascript">
$(document).ready(function(){
$(".button1").click(function(){
$(".div2").slideUp('slow');
$(".div3").slideUp('slow');
$(".div1").slideDown('slow');
$(this).toggleClass("active"); return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".button2").click(function(){
$(".div1").slideUp('slow');
$(".div3").slideUp('slow');
$(".div2").slideDown('slow');
$(this).toggleClass("active"); return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".button3").click(function(){
$(".div1").slideUp('slow');
$(".div2").slideUp('slow');
$(".div3").slideDown('slow');
$(this).toggleClass("active"); return false;
});
});
</script>
Thanks in advance!!!