Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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%", ...});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #set #multiple #attributes #javascript
ADD COMMENT
Topic
Name
3+7 =