I want to toggle class using jquery If Else statement for specified conditions.
My Html with default css class=\"horizontal\"
class=\"horizontal\"
There is a toggleClass method that does this; it even works with multiple class names separated by spaces. So toggle both of them, no matter what's the current class of the element:
$("#foo-bar").toggleClass("horizontal vertical");