Compares an HTMLElement's classList against an array of strings to see if any match.

Parameters:
NameTypeDescription
elHTMLElement

The element to check against.

arrArray

The array of classes as strings to test against.

prefixstring

Optional prefix string applied to all test strings.

suffixstring

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
  }
}