I have a nice little button which uses a lot of fancy CSS to look good.

Here's the code behind it (I'm ignoring compatibility issues for now); as you can see, it uses a few selectors for hover and click events.
.button {
display: inline-block;
width: 200px;
height: 200px;
padding: 15px;
border-radius: 25px;
background:linear-gradient(to bottom, hsla(36, 100%, 60%, 1) 5%, hsla(36, 100%, 40%, 1) 100%);
border:2px solid hsla(36, 100%, 30%, 1);
box-shadow:inset 0px 2px 2px 0px white;
position: relative;
left: 0px;
top: 0px;
text-shadow:0px 1px 0px hsla(36, 100%, 30%, 1);
margin: 25px;
}
.button:hover {
background:linear-gradient(to bottom, hsla(36, 100%, 65%, 1) 5%, hsla(36, 100%, 45%, 1) 100%);
}
.button:active {
background:linear-gradient(to bottom, hsla(36, 100%, 40%, 1) 5%, hsla(36, 100%, 60%, 1) 100%);
}
However, to streamline the process in the future when there will be many buttons, I instead wanted to be able to make the button have a custom attribute for colour (buttonColor below) which will be read by some JavaScript, turned into Hue/Saturation/Lightness, and eventually changed for the many different variations. Each button contains at least three colours; two for the gradient and one for the drop shadow and border.
<div class="button" id="testButton"buttonColor="ff8c00">
<p class="buttonHeader">foo</p>
<p class="buttonBody">foo2</p>
</div>
Here's what I've got in the JavaScript:
function hexToRgb(hex) { //converts hexadecimal colors into Red/Green/Blue
//code omitted for sake of conciseness
return [r, g, b];
}
function rgbToHsl(r, g, b) { //converts Red/Green/Blue into Hue/Saturation/Lightness
//ditto
return [h, s, l]
}
var buttons = document.body.getElementsByClassName('button'); //Gets all elements with button class
for (var i = 0; i < buttons.length; i++) {
var rgb = hexToRgb(buttons[i].getAttribute("buttoncolor")); //
var hsl = rgbToHsl(rgb.r, rgb.g, rgb.b)
//here
}
And right there is where I'm stuck.
I can easily modify the style of the button, but only while it's inactive; There's no way I've found to change how it reacts under the :hover and :active selectors.
and eventually changed for the many different variationshow do you plan on changing to many variations? or is that the issue? and can you post all of your JS if there is more?