> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/manipulation/.hasattr.md).

# .hasAttr()

The `hasAttr` method checks if an element  have specific attributes.&#x20;

***

#### **Returns**

* `true` if all specified attributes exist.
* `false` otherwise.

#### **Usage**

**For Single Elements**

```javascript
$('.button').hasAttr('id'); // Checks if the element has an 'id' attribute
$('.link').hasAttr('href', 'target'); // Checks for multiple attributes
```

**For Collections**

```javascript
$('img*').hasAttr('src'); // Checks if all <img> elements have a 'src' attribute
$('input').hasAttr('type', 'name'); // Checks if all <input> elements have both attributes
```
