I am looking for some help with a picky one. I try to change the icon in the headers when they are active, but cannot solve the problem if I click on another heading without closing the first one that displays the corresponding icon.
Here is the code with an example of my problem.
http://codepen.io/FPC/pen/xZEWVY
here is my code:
<div class="container">
<div class="row">
<div class="col s6">
<ul class="collapsible popout" data-collapsible="accordion">
<li>
<div class="collapsible-header">
<i class="material-icons right more">expand_more</i>
<i class="material-icons right less" style="display: none">expand_less</i>
Article Title
</div>
<div class="collapsible-body">
<p>
Content Snipit
</p>
</div>
</li>
<li>
<div class="collapsible-header">
<i class="material-icons right more">expand_more</i>
<i class="material-icons right less" style="display: none">expand_less</i>
Article Title
</div>
<div class="collapsible-body">
<p>
Content Snipit
</p>
</div>
</li>
<li>
<div class="collapsible-header">
<i class="material-icons right more">expand_more</i>
<i class="material-icons right less" style="display: none">expand_less</i>
Article Title
</div>
<div class="collapsible-body">
<p>
Content Snipit
</p>
</div>
</li>
</ul>
</div>
</div>
</div>
here is js i'm using
$(document).ready(function(){
$( ".collapsible-header" ).click(function() {
$(".more",this).toggle()
$(".less", this).toggle()
});
});
source
share