I want to toggle class using jquery If Else statement for specified conditions.
My Html with default css class=\"horizontal\"
In case you do not want to use the toogleClass(), here is another solution:
http://jsfiddle.net/YFBWQ/
$('#foo-bar')
.removeClass('horizontal vertical')
.addClass( myvar=='layout2' ? 'vertical' : 'horizontal')
or
$('#foo-bar')
.removeClass(myvar=='layout2' ? 'horizontal' : 'vertical')
.addClass(myvar=='layout2' ? 'vertical' : 'horizontal')