set attribute for multiple elements code example
Example 1: set multiple attributes javascript
// create a helper function
function setAttributes(el, attrs) {
for(var key in attrs) {
el.setAttribute(key, attrs[key]);
}
}
// call like this
setAttributes(elem, {"src": "http://example.com/something.jpeg", "height": "100%", ...});
Example 2: set multiple attributes css javascript
document.getElementById("myElement").style.cssText = "display: block; position: absolute";