Usually you can use .toggleClass()
to switch on/off a specific class eg. .toggleClass('on')
But, How can I toggle between two different classes, eg. left / right?
My situation: I use a parent div
and I want to toggle left or right class to change the sidebar position.
<div id="page" class="left">
<div id="sidebar"></div>
<div id="container"></div>
</div>
css:
#sidebar {width:25%;}
#container {width:75%;}
#page.right #container,
#page.left #sidebar {float:left;}
#page.left #container,
#page.right #sidebar {float:right;}
I hate to use if is left than add right else ...