Compares an HTMLElement against an array of selectors to see if it is one of them or is contained within any of them.
Parameters:
Name | Type | Description |
---|---|---|
target | HTMLElement | The element to check against. |
selectors | Array | The array of selectors to test against. |
- Since
- 1.0.0
Returns:
Returns true if the element is one of them or is contained within any of the selectors.
- Type:
- boolean
Example
import { matchesOrContainedInSelectors } from "@gravityforms/utils";
function Example() {
const exampleTarget = getNodes( '.some-target-selector', false, document.body, true )[ 0 ];
const exampleSelectors = [ '.node-selector-one', '.node-selector-one' ];
if( matchesOrContainedInSelectors( exampleTarget, exampleSelectors ) ) {
//do something
}
}