I have two columns, A & B. Some items in A open multiple items in B. A will toggle its corresponding B Items - BUT clicking on an A that includes an already opened B starts to mess up the toggle.
I want each item in A to open its respective items in B and if one or more of those items are already open then don't close them. Clicking on A again should close its corresponding items in B.
I feel like I'm really close - I've been looking at this for too long:
<style>
#aItems li, h3.bTitle{ cursor: pointer;}
/* shell - structure */
#wrap { width:870px; margin:0 auto;}
#leftcolumn { width: 250px; float: left; margin-right: 30px; }
#rightcolumn { width: 590px; float: right;}
/* Indicators */
.activeAye{color:blue;}
.beeOpen{color:red;}
/* Start Hidden */
.bItem { display: none;}
</style>
<script>
jQuery( document ).ready(function( $ ) {
/* Column A*/
/* Click Item A -> Expand Relevant B's */
$('.aItem').click(function(){
$(this).toggleClass('activeAye');
$('.aItem').not(this).removeClass('activeAye');
// Define target B's
var beeTarget = $(this).data('bdesc');
// Toggle Targets
$(beeTarget).slideToggle("medium").prev('h3').toggleClass('beeOpen');
});
/* Column B */
$(".bTitle").click(function(){
// toggle bItem div open/close
$(this).next('.bItem').slideToggle("medium");
});
});
</script>
<div id="wrap">
<h1>Overlapping Div Sets</h1>
<ul>
<li>Item in Column A toggle open/close relevant descriptions on the items in column B.</li>
<li>Clicking on another Item in A should:
<ul>
<li>Close non-relevant B Items</li>
<li>Keep open any relevant ones</li>
<li>Open any that are closed</li>
</ul>
</li>
<li>Clicking any Item in B directly will toggle it open/closed - with no impact to A->B functionality</li>
</ul>
<div id="leftcolumn">
<h4>Column A</h4>
<ul id="aItems">
<li class="aItem ayeOne" data-bdesc=".beeOne"><h3>A One</h3>Toggle B1</li>
<li class="aItem ayeTwo" data-bdesc=".beeOne, .beeTwo"><h3>A Two</h3>Toggle B1 and B2</li>
<li class="aItem ayeThree" data-bdesc=".beeOne, .beeThree"><h3>A Three</h3>Toggle B1 and B3</li>
<li class="aItem ayeFour" data-bdesc=".beeFour"><h3>A Four</h3>Toggle B4</li>
<li class="aItem ayeFive" data-bdesc=".beeFive"><h3>A Five</h3>Toggle B5</li>
<li class="aItem ayeSix" data-bdesc=".beeSix"><h3>A Six</h3>Toggle B6</li>
</ul>
</div><!-- /#leftcolumn -->
<div id="rightcolumn">
<h4>Column B</h4>
<h3 class="bTitle">B One</h3>
<div class="bItem beeOne">Nam at tortor in tellus interdum sagittis.</div>
<h3 class="bTitle">B Two</h3>
<div class="bItem beeTwo">In hac habitasse platea dictumst.</div>
<h3 class="bTitle">B Three</h3>
<div class="bItem beeThree">Cras dapibus.</div>
<h3 class="bTitle">B Four</h3>
<div class="bItem beeFour">Suspendisse eu ligula.</div>
<h3 class="bTitle">B Five</h3>
<div class="bItem beeFive">Sed hendrerit.</div>
<h3 class="bTitle">B Six</h3>
<div class="bItem beeSix">Aenean imperdiet.</div>
</div><!-- /#rightcolumn -->
</div><!-- /#wrap -->