I am trying to get a hidden nested ul to display when a div in its parent li is clicked, and am having a heck of a time with it. As is, the initial hiding of the nested ul's works, and the div background image toggles just fine, but nothing else is working. Any suggestions?
Current code below:
HTML:
<div class="browseFields">
<ul id="branches">
<li><div class="buttonShow"></div><a href="#">1</a>
<ul class="subField">
<li><a href="#">a</a></li>
<li><a href="#">b</a></li>
<li><div class="buttonShow"></div>
<ul class="subField">
<li><a href="#">i</a></li>
<li><a href="#">ii</a></li>
<li><a href="#">iii</a></li>
</ul>
<a href="#">c</a>
</li>
</ul>
</li>
<li><a href="#">2</a></li>
<li><div class="buttonShow"></div><a href="#">3</a>
<ul class="subField">
<li><a href="#">a</a></li>
<li><a href="#">b</a></li>
<li><a href="#">c</a></li>
</ul>
</li>
</ul>
</div>
Relavent CSS:
.buttonShow {
display: inline-block;
background: url("../assets/images/plus.png") no-repeat scroll top left;
width: 9px;
height: 9px; }
.buttonHide {
display: inline-block;
background: url("../assets/images/minus.png") no-repeat scroll top left;
width: 9px;
height: 9px; }
jQuery:
$(document).ready(function(){
$('.subField').hide();
$('.buttonShow').click(function() {
$(this).toggleClass('buttonHide');
$(this).parent().next('.subField').show('slow');
});
$('.buttonHide').click(function() {
$(this).parent().next('.subField').hide('slow');
});
});
Thanks so much!