---
schema_version: "1"
id: 95968d404fb91ed21ca54f51d81a942ca111550566201485e6d7c123be981cc5
title: hasClass()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/ref-jsapi/ref-jsapi-util-hasclass.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-util-hasclass.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0f213a787e95be79c8457e35aa3c8cf76aecfe57a6893821d406acfd74daa230
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# hasClass()

Checks whether the component has the specified CSS class.

## Signature

`hasClass(Object element, String className)`

## Parameters

**_element_:** Type: `Object`. The component to check.

**_className_:** Type: `String`. The CSS class name to check for.

## Returns

**Type: `Boolean`** Returns `true` if the specified class is found for the component, or `false` otherwise.

## Sample Code

```javascript
// find a component with aura:id="myCmp" in markup
var myCmp = component.find("myCmp");
$A.util.hasClass(myCmp, "myClass");
```

