jQuery changing css class to div

前端 未结 6 692
傲寒
傲寒 2020-12-14 06:35

If I have one div element for example and class \'first\' is defined with many css properties. Can I assign css class \'second\' which also has many properties differently

6条回答
  •  甜味超标
    2020-12-14 06:40

    You can add and remove classes with jQuery like so:

    $(".first").addClass("second")
    // remove a class
    $(".first").removeClass("second")
    

    By the way you can set multiple classes in your markup right away separated with a whitespace

提交回复
热议问题