javascript - JQuery/JS onclick change class of element inside link clicked -
i have couple of drop downs using bootstrap , want code in simple function change class of span element inside link clicked.
to clarify... here's example of html have:
<a data-toggle="collapse" href="#collapse-panel" aria-expanded="false" onclick="toggleicon()"> <span class="glyphicon glyphicon-knight"></span> drop down title <span class="glyphicon glyphicon-triangle-bottom"></span> </a> <div class="collapse" id="collapse-panel"> <!-- content --> </div> i looking function (using js or jquery) can toggle second span class change between glyphicon glyphicon-triangle-bottom , glyphicon glyphicon-triangle-top.
bear in mind, function has work multiple drop-downs. appreciated.
$('a[data-toggle="collapse"]').click(function(){ $(this).find('.glyphicon-triangle-bottom, .glyphicon-triangle-top').toggleclass('glyphicon-triangle-top glyphicon-triangle-bottom'); }); also remove onclick="toggleicon()"
this should work anchor tags have data-toggle="collapse" attribute.
Comments
Post a Comment