I found this question on editing css styles in Javascript, in which the solution is to use
document.getElementById('element').style.MozBoxShadow = "1px 1px 1px #000";
I am trying to write a function that takes an array of parameters to edit as so:
var element = document.getElementById('element');
editElementStyles(element, new Array("width", "100%", "height", "100%"...etc.));
And the function:
function editElementStyles(element, args) {
for (var i = 0; i < args.length; i += 2) {
element.style.args[i] = args[i + 1];
}
}
However, this of course does not work as args[i] is not a property of element.style. How can I make this work?
new Array(elem1, elem2, elem3, ...)can be expressed more simply as[elem1, elem2, elem3, ...].