Skip to content
0

katanakit-js / useHasClass

Function: useHasClass() ​

ts
function useHasClass(target, className): boolean;

Defined in: src/infrastructure/dom/dom.service.ts:215

Checks whether the target element has a given CSS class.

Parameters ​

ParameterTypeDescription
targetstring | ElementA CSS selector string or an Element instance.
classNamestringThe class name to check.

Returns ​

boolean

true if the class exists, false otherwise.

Example ​

ts
if (useHasClass(".btn", "disabled")) {
  // button is disabled
}

Released under the MIT License.