To toggle (add/remove) css class of an html element, toggleClass()
method can be used.
<script>
$("#btnToggleClass").click(function () {
$("#div2").toggleClass("class1");
});
</script>
Above code will toggle class “class1” to the element whose id is “div2” on the button (whose id is “btnToggleClass”) click event.
Views: 6197 | Post Order: 37