1// create a helper function
2function setAttributes(el, attrs) {
3 for(var key in attrs) {
4 el.setAttribute(key, attrs[key]);
5 }
6}
7
8// call like this
9setAttributes(elem, {"src": "http://example.com/something.jpeg", "height": "100%", ...});
1document.getElementById("myElement").style.cssText = "display: block; position: absolute";