JavaScript hasAttributes() Method Tutorial

In this section, we will learn what the Element hasAttributes() method is and how to use it in JavaScript.

What is Element hasAttributes() Method in JavaScript?

The JavaScript Element hasAttributes() method is used to see if the target element has any attribute set for it!

If that element has any attribute, the return value of this method will be true. Otherwise, the value false will return instead.

Element hasAttributes() Method Syntax:

element.hasAttributes();

Element hasAttributes() Method Parameter

The method does not take an argument.

Element hasAttributes() Method Return Value

The return value of this method is of type boolean.

It will be true if the target element had one or more attributes set. Otherwise, the value false will return instead.

Example: using hasAttributes() method in JavaScript

See the Pen using hasAttributes() method in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies