/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: hasAttribute()

[this page | pdf | back links]

The hasAttribute() method (when applied to HTML elements in the JavaScript DOM) returns true if the element has the specified attribute, otherwise it returns false.

 

It has the following syntax with the following parameters. It returns a Boolean as above.

 

element.hasAttribute(attributename)

 

Parameter

Required / Optional

Description

attributename

Required

String containing name of attribute

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile