jQuery changing css class to div

前端 未结 6 683
傲寒
傲寒 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:50

    $(".first").addClass("second");
    

    If you'd like to add it on an event, you can do so easily as well. An example with the click event:

    $(".first").click(function() {
        $(this).addClass("second");
    });
    

提交回复
热议问题