jquery - Use Javascript to select a colour declared in CSS -


I am using to create a donut chart. The colors for each section are defined in the options passed through JS.

  self.chartView = new donut ({el: this, color: ['# 96c6e3', '# d8c395', '# 7fb299', '# c693c3'], data: $ ( This) .data ('series')});  

I want to define these colors in CSS and then want to catch them for the donut chart. Some on the lines of:

CSS

  # color1 {background-color: # 96c6e3; }  

JS

  self.chartView = new donut ({el: this, color: [$ ('# 1 Color '). CSS (' background-color ')], data: $ (this). Data (' series')});  

But I do not even know that this is possible.

For example:

JS:

 < Code> var color = [$ ('# color1'). CSS ('background color'), $ ('# color2'). CSS ('background color')]; $ ('# Container'). High Chart ({Color: Color, Series: [{Type: 'Pie', Name: 'Browser Share', Data: [['Firefox' ', 45.0], [' IE ', 26.8]]}]});  

HTML:

  & lt; Div id = "colors" & gt; & Lt; Div id = "color1" & gt; & Lt; / Div & gt; & Lt; Div id = "color2" & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

CSS:

  # color 1 {background-color: # 96c6e3; } # Color 2 {background color: red; } #colors {display: none; }  

Comments