Compares an HTMLElement's classList against an array of strings to see if any match.
Parameters:
Name | Type | Description |
---|---|---|
el | HTMLElement | The element to check against. |
arr | Array | The array of classes as strings to test against. |
prefix | string | Optional prefix string applied to all test strings. |
suffix | string | Optional suffix string. |
- Since
- 1.0.0
Returns:
Returns true if a matching css selector is found.
- Type:
- boolean
Example
import { hasClassFromArray, getNodes } from "@gravityforms/utils";
function Example() {
const example = getNodes( '.some-custom-selector', false, document.body, true )[ 0 ];
if( hasClassFromArray( example, [ 'one-class-string', 'another-class-string' ], 'gform-' ) ) {
//do something
}
}