Skip to content

Function: setOpacity()

ts
function setOpacity(elem, opacity): void;

Set the opacity of an element.

Parameters

ParameterTypeDescription
elemanyThe element whose opacity to set.
opacitynumberThe opacity value to set.

Returns

void

Example

ts
const el = document.createElement('div')
setOpacity(el, 0.5)
console.log(el.style.opacity)

Since

1.0.0

Released under the MIT License.