.hasAttribute()

String? Element.hasAttribute(String name)

Returns the value of the specified attribute.

element.hasAttribute(name);

Returns true if element has attribute name.

Example

HTML:

<input type="checkbox">

JavaScript:

let result = document.query("input").hasAttribute("type");

Result is true.