When I click on the span that is within the section, the list within only that section is supposed to be toggled. What happens though is that every list within every section is toggled, not just the one that belongs to the section that I am clicking on.
HTML:
<section class="tutorial-box">
<p>
<a href="#">Link #1</a>
<br />
Some text.
<br />
<span class="view-contents plus-sign">Click Here</span>
</p>
<ul class="tutorial-box-list">
<li><a href="#">link</a></li>
<li><a href="#">link</a></li>
</ul>
<div class="clear"> </div> <!-- end div class clear -->
</section> <!-- end section class tutorial-box -->
<section class="tutorial-box">
<p>
<a href="#">Link #2</a>
<br />
Some more text.
<br />
<span class="view-contents plus-sign">Click Here</span>
</p>
<ul class="tutorial-box-list">
<li><a href="#">link</a></li>
<li><a href="#">link</a></li>
</ul>
<div class="clear"></div> <!-- end div class clear -->
</section> <!-- end section class tutorial-box -->
CSS:
.tutorial-box{
clear: both;
width: 100%;
height: auto;
margin: 5px 0 10px 0;
padding: 0;
}
.tutorial-box p{
margin: 5px 0;
padding: 0;
}
.view-contents{
margin: 0;
padding: 0 0 0 20px;
cursor: pointer;
}
.plus-sign{
margin: 0;
padding: 0 0 0 20px;
background: url("../images/plus-icon.png") 0 0 no-repeat;
}
.minus-sign{
margin: 0;
padding: 0 0 0 20px;
background: url("../images/minus-icon.png") 0 0 no-repeat;
}
jQuery / JavaScript:
$(document).ready(function(){
$('.tutorial-box-list').hide();
$('.view-contents').click(function() {
if($('.tutorial-box span').hasClass('plus-sign')) {
$('.tutorial-box-list').slideToggle('2000');
$('.tutorial-box span').addClass('minus-sign').removeClass('plus-sign');
}
else {
$('.tutorial-box-list').slideToggle('2000');
$('.tutorial-box span').addClass('plus-sign').removeClass('minus-sign');
}
});
$('.toggle').each(function(){
$(this).find('.toggle-content').hide();
});
});
Any help will be appreciated.