I want to submit my own variable in the style object. I will show you what I mean:
var example = background
element.style.example // example is equal to the variable up top
Is there any with of doing this?
I want to submit my own variable in the style object. I will show you what I mean:
var example = background
element.style.example // example is equal to the variable up top
Is there any with of doing this?
You can use bracket notation
var example = "background";
element.style[example] = "#fff";
Assuming you want to define the property to be set dynamically, you could use the following approach:
var example = 'background';
element.style[example] = 'black';