How to add new class with existing class dynamically using Jquery/Javascript -


i need 1 help. need add 1 new class along existing class using jquery/javascript. explaining code below.

<div class="fynd-space-itms"> <div class="col-sm-3">     <a href="javascript:void(0)" class="item-exhibitation maploc" onclick="keepsection();">ram</a></div> <div class="col-sm-3"> <a href="javascript:void(0)" class="item-parking maploc" onclick="keepsection();">raj</a></div> <div class="col-sm-3"> <a href="javascript:void(0)" class="item-offices maploc" onclick="keepsection();">ray</a>     </div> </div> 

here need when user click on onclick event 1 new class add along existing class. suppose user clicked on ram , after clicking new class i.e-active add , total class name item-exhibitationactive maploc , same others i.e-item-parkingactive maploc,item-officesactive maploc. @ same time other anchor tag active class remove if added before. please me.

in jquery try this:

$('.maploc').click(function(){   $('.maploc').removeclass('active');  // remove added class   $(this).addclass('active'); }); 

working fiddle


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -