Inserts an HTMLElement before another one that is passed in.
Parameters:
Name | Type | Description |
---|---|---|
element | HTMLElement | | The element to insert. |
target | HTMLElement | | The target to insert the element before. |
- Since
- 1.0.0
- Source
Returns:
- Type:
- void
Example
import { insertBefore, getNodes } from "@gravityforms/utils";
function Example() {
const target = getNodes( '.some-custom-selector', false, document.body, true )[ 0 ];
const div = document.createElement( 'div' );
insertBefore( div, target );
}