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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -