how to add and remove css class

后端 未结 5 1663
清歌不尽
清歌不尽 2021-01-21 06:18

how to remove CSS default class

This is my div

This is my css class

#messageContai         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 06:42

    You aren't dealing with a class. You have default rules applied to the ID element. As such, you should really only need to add the new class:

    $("#messageContainer").addClass("newRules");
    

    Any rules that aren't overwritten can be overwritten with the css() method:

    $("#messageContainer").css({
      'font-weight':'bold',
      'color':'#990000'
    }).addClass("newRules");
    

提交回复
热议问题