Update snippet descriptions
This commit is contained in:
@ -3,9 +3,9 @@ title: hasClass
|
||||
tags: browser,css,beginner
|
||||
---
|
||||
|
||||
Returns `true` if the element has the specified class, `false` otherwise.
|
||||
Checks if the given element has the specified class.
|
||||
|
||||
- Use `element.classList.contains()` to check if the element has the specified class.
|
||||
- Use `Element.classList` and `DOMTokenList.contains()` to check if the element has the specified class.
|
||||
|
||||
```js
|
||||
const hasClass = (el, className) => el.classList.contains(className);
|
||||
|
||||
Reference in New Issue
Block a user