How to toggle class using jquery if else statement?

前端 未结 5 1497
渐次进展
渐次进展 2021-01-20 17:14

I want to toggle class using jquery If Else statement for specified conditions.

My Html with default css class=\"horizontal\"

5条回答
  •  时光取名叫无心
    2021-01-20 17:33

    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");
    

提交回复
热议问题