/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: getAttribute()

[this page | pdf | back links]

The getAttribute() method (when applied to HTML elements in the JavaScript DOM) returns the value of the specified attribute.

 

It has the following syntax with the following parameters. It returns a String representing the value of the specified attribute. If the attribute does not exist then the return value will be null or an empty string, i.e. "".

 

element.getAttribute(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