Search
 
SCRIPT & CODE EXAMPLE
 

CSS

DOM element add multiple attributes

function setAttributes(element, attributes) {
  Object.keys(attributes).forEach(attr => {
    element.setAttribute(attr, attributes[attr]);
  });
}

const attributes = {
  name: 'example',
  title: 'Box 1',
  disabled: '',
  style: 'background-color: salmon; color: white;',
};

const button = document.getElementById('btn');
setAttributes(button, attributes);
Comment

how to apply multiple attributes using js

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

PREVIOUS NEXT
Code Example
Css :: login page design html css 
Css :: max character css 
Css :: wrap text around circle image css 
Css :: css class id 
Css :: flex decoration css 
Css :: gradient btn 
Css :: how to remove default padding of div 
Css :: css grid container 
Css :: div set text colo0r 
Css :: fix scroll css position sticky 
Css :: backdrop filter all properties 
Css :: css flexbox syntax 
Css :: make border absolute css 
Css :: css materialize 
Css :: css witdh 
Css :: scss darken 
Css :: Change the color of anchor tags 
Css :: css forbidden cursor 
Css :: css target type 
Css :: what is the animation property in html and css 
Css :: remove text color from link 
Css :: make background overlay css 
Css :: truncate multiline text 
Css :: css selector last child 
Css :: pesudo content css break word 
Css :: background image syntax in css if it in folder 
Css :: transform css 
Css :: create variable in css 
Css :: overflow touch smooth 
Css :: css icon 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =