jQuery > Attribute related method

.toggleClass() - Toggle class attribute in jQuery

How to toggle the class attribute value of an element in jQuery?

To toggle (add/remove) css class of an html element, toggleClass() method can be used.

       $("#btnToggleClass").click(function () {

Above code will toggle class “class1” to the element whose id is “div2” on the button (whose id is “btnToggleClass”) click event.

 Views: 1034 | Post Order: 37

Write for us