jquery - How to toggle a specific class on an element where there are multiple classes assigned? -


I have an element in which there are multiple classes when I click it, then switch between any of the classes Want to

  & lt; Span class = "icon-expand-desktop-only mt8 pl4" id = "toggle-site-content-width" & gt; & Lt; / Span & gt;  

When I click it, I just have to change the icon-extension to icon-less , and just to other sections Leave it

When I am using $ (this) .toggleClass ('icon-less'), then it adds the class to the end . This is what happens when I am doing this: $ (this) .toggleClass ('icon-expand', 'icon-less') .

This is the full code:

  $ (function () {$ ('# toggle-site-content-width'). (Function () {/ / Click $ ('# site-content'). Children ('Div') Toggleclass ('content-align-center'); // to expand this square fully available window width $ (this) Replace Toggle Class ('Toggle-Extension', 'Icon-less'); // icon $ (this). Transger ('resize'); // Window to rearrange masonry bricks Trigger}}}};  

You have to change:

  $ (this) .toggleClass ('toggle-extension', 'icon-less');  

From:

  $ (this) .toggleClass ('Toggle-Extend Icons-Reduce');  

Classes need not be separated from , .


Comments