2015-10-13 41 views
0

我有很多面板,並希望在計數器爲10後更改主面板的顏色;CSS如何更改if塊中特定主面板的顏色

this.dateUpdate = function (element) { 
     if (hasfocus == element) { 
     dateCounter += 1; 
      if (dateCounter == 10) { 
       element.addClass('changecolor'); 
       dateCounter = 0; 
      } 
     } 
    }; 

這不是工作:

.changecolor > .panel-primary { 
    background-color: #e1e1e1 !important; 
} 

要記住,我只是想改變特定的一個,而不是全部。

Thx提前。

+0

嘗試用panel-primary替換changecolor – brk

回答

1

如果panel-primary DIV裏面changecolor

.changecolor .panel-primary { 
    background-color: #e1e1e1 !important; 
} 

如果panel-primary DIV是在changecolor類得到應用的

.changecolor.panel-primary { 
    background-color: #e1e1e1 !important; 
} 
+1

我與.changecolor.panel-primary一起工作謝謝!!! – trap

0

代替element.addClass同一div嘗試element.setAttribute("class", "changecolor");

+0

我得到了錯誤:element.setAttribute不是一個函數 – trap