Menu

gitpiper

addStyles javascript Code Snippet in 2023

browserbeginner

Last Updated: 4 February 2023

Adds the provided styles to the given element.

  • Use Object.assign() and ElementCSSInlineStyle.style to merge the provided styles object into the style of the given element.
const addStyles = (el, styles) => Object.assign(el.style, styles);
addStyles(document.getElementById('my-element'), { background: 'red', color: '#ffff00', fontSize: '3rem' });

javascript snippet similar to addStyles For You in February 2023

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2023 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️