Hover function for accordion
- by Banderdash
Thus far you guys have been wildly helpful with me getting this little ditty working just so. I have one further request:
This markup:
<div id="themes">
<h2>Research Themes</h2>
<ul>
<li class="tier_1"><a class="enviro" href="">Learn about our approach to the <strong>environment</strong></a>
<ul class="tier_2 hide">
<li><a href=""><em>How we are tying this all together</em></a></li>
<li><a href="off.html"><strong>Project:</strong> Solor Powered Biofactories</a></li>
<li><a href=""><strong>Project:</strong> Cleaning Water with Nature</a></li>
<li><a href=""><strong>Project:</strong> Higher Efficiency Solar Technology</a></li>
</ul>
</li>
<li class="tier_1"><a class="health" href="">Learn about our approach to <strong>human health</strong></a>
<ul class="tier_2 hide">
<li><a href="">Project name numero uno goes here</a></li>
<li><a href="">Project name numero dos goes here</a></li>
<li><a href="">Project name numero tres goes here</a></li>
</ul>
</li>
<li class="tier_1"><a class="defense" href="">Learn about our approach to <strong>national defense</strong></a>
<ul class="tier_2 hide">
<li><a href="">Project name numero uno goes here</a></li>
<li><a href="">Project name numero dos goes here</a></li>
<li><a href="">Project name numero tres goes here</a></li>
</ul>
</li>
</ul>
</div><!-- // end themes -->
And this jQuery:
$(function(){
$(".tier_1 > a").hover(function() {
var currentList = jQuery(this).parents('li').find('.tier_2');
$(currentList).slideToggle();
jQuery(this).parents('ul').find('.tier_2').not(currentList).slideUp();
return false;
});
});
Create this nifty 'themes' slider you can see working on the right column of this page: http://clients.pixelbleed.net/biodesign/
I have two problems with it...The hover retracts the slideUp/down when you hit one of the links under a tier_2 ul. I'd like it to remain slideout as someone hovers the nested li's. So the slide should only happen on hover for the tier_1 elements. Also I would like, on hover to add an "active" class to the a element on the tier_1 links. So [a class="enviro"..] would, on hover, become [a class="enviro active"]. This is then removed when one of the other tier_1 items is hovered. This way the pretty color icon can stay visible while someone looks at the nested elements.
Not even sure all that is possible with hover, but I figured if anyone would know a way it would be here.