Notes on Day 26 of 30 Days of JavaScript

Table of Contents

Lessons Learned

CSSStyleDeclaration.setProperty()

This sets new key-value pairs for the style attribute of a DOM element.

const container = document.querySelector(".container")
containter.style.setProperty("background", "#CCCCCC")

This is another alternative to the camelcased CSS attribute shorthand if you are not sure of their representation as a CSSStyleDeclaration.cssText property inline name.

const container = document.querySelector(".container")
containter.style.background = "#CCCCCC"

References

Twitter, LinkedIn