The getAttribute() method is used to obtain the value of an attribute in an html document . In an html code, attribute and its value appear as a key value pair. Some of the commonly known html attributes are disabled, alt, id, href, style, title and src.