How can I prevent both “inner” divs from being visible at the same time. Say if one is visible, and the other is called, the one currently active should slideUp before the new one slidesDown.
HTML:
<div class="redirectWrap">
<a id="redirectDefault" class="redirectOuter" href="#">
<h4>Default URL</h4>
<span>test.com/tctc91</h4>
</a>
<a id="redirectCustom" class="redirectOuter" href="#">
<h4>Custom URL</h4>
<span>m.tomchristian.co.uk</h4>
</a>
<div class="redirectDefaultInner redirectBox hide">
test
</div>
<div class="redirectCustomInner redirectBox hide">
test
</div>
</div>
jQuery:
$('.redirectOuter').click(function() {
$(this).parent().find('.'+$(this).attr('id')+'Inner').slideUp('fast');
return false;
});
$('.redirectOuter').click(function(e){
var inner = $(this).parent().find('.'+$(this).attr('id')+'Inner');
if(!inner.is(":visible")) {
inner.stop().slideDown('fast');
}
e.stopPropagation();
});
Edit:
Updated your code to make it work as you wanted,
DEMO
I think jQuery accordion is what you need.
DEMO
With some changes to your markup,
And JS: