Modifies a DOM element.
- Source:
Methods
(static) modifyElement(element, attributesopt) → {HTMLElement}
- Source:
Example
import { modifyElement } from '@untemps/utils/dom/modifyElement'
const element = document.createElement('div')
element.className = 'foo'
document.body.appendChild(element)
modifyElement(element, { className: 'bar' }) // <div class="bar"></div>
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
element |
HTMLElement | The DOM element to modify. |
||
attributes |
object.<string, *> |
<optional> |
{}
|
The new attributes to set to the DOM element. |
Returns:
The modified DOM element.
- Type
- HTMLElement