Point one style class to another?

前端 未结 10 1391
遇见更好的自我
遇见更好的自我 2021-02-04 23:59

I have a css class like:

.foo {
  background-color: red;
}

then I have a class specified for a list:

.list1 li {
  background-c         


        
10条回答
  •  春和景丽
    2021-02-05 00:28

    I've a litte expand @Frank Carnovale solution (without css changing). After page loading:

    $(function () {
       $('.list li').removeClass('old1 old2 ...')
       $('.list li').toggleClass('foo1 foo2 ...')
    }
    

    See also Does addClass in JQuery override any existing css class based styles?

提交回复
热议问题