I want to toggle class using jquery If Else statement for specified conditions.
My Html with default css class=\"horizontal\"
class=\"horizontal\"
You can use the switch in toggleClass().
A Boolean value to determine whether the class should be added or removed.
$('#foo-bar').toggleClass('horizontal', myvar==layout1) .toggleClass('vertical', myvar==layout2);