JS DOM: Change HTML element style attribute

By Xah Lee. Date: .

Get style

node.style.cssProperty

Return the property value, or undefined if it doesn't exist.

Set style

node.style.cssProperty=value
  • Set CSS property.
  • Return value.
  • If the property is not a standard CSS property, it's not added.

example JS DOM: Change CSS