Search
 
SCRIPT & CODE EXAMPLE
 

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%", ...});
Comment

how to apply multiple attributes using js

Object.assign(element,{...attributes})
Comment

PREVIOUS NEXT
Code Example
Javascript :: Angular Unit Testing: Observable not returning results 
Javascript :: js one line if 
Javascript :: js docstring example 
Javascript :: array remove empty entrys js 
Javascript :: send xmlhttprequest with axios 
Javascript :: delay javascript function 
Javascript :: how to import jquery in js file 
Javascript :: JavaScript - The first word of a string 
Javascript :: angular cli path environment variable 
Javascript :: how to delete node_modules file 
Javascript :: dynamically adding marker react native mapbox 
Javascript :: array methods javascript 
Javascript :: typescript css variables 
Javascript :: javascript game loop 
Javascript :: exceljs read file 
Javascript :: search if value exists in object javascript 
Javascript :: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project electronicbookshop: Compilation failure 
Javascript :: how to call datetime in javascript 
Javascript :: get element by 
Javascript :: text to 64base javascript 
Javascript :: get cookie javascript 
Javascript :: how to generate color code from random number 
Javascript :: how to find the index of a value in an array in javascript 
Javascript :: jquery serialize form data to object 
Javascript :: get the integer after decimal in javascript 
Javascript :: remove appended element jquery 
Javascript :: how to check if a string is in a string js 
Javascript :: go to top angular 
Javascript :: test undefined js 
Javascript :: d3.json() function 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =