Applies a style to the element by adding a CSS declaration.
The first parameter, property
, is a string. If the name of a style property is passed, as in myElement.style('color')
, the method returns the current value as a string or null
if it hasn't been set. If a property:style
string is passed, as in myElement.style('color:deeppink')
, the method sets the style property
to value
.
The second parameter, value
, is optional. It sets the property's value. value
can be a string, as in myElement.style('color', 'deeppink')
, or a p5.Color object, as in myElement.style('color', myColor)
.
Examples
Syntax
style(property)
style(property, value)
Parameters
property
String:
style property to set.
value
String|p5.Color:
value to assign to the property.
Returns
String: value of the property.
Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!