Note: using this method, we get the string value of the specified attribute. But there’s another method called getAttributeNode() that will return an AttributeNode object that has a bunch of methods and properties by which you can get the value of the specified attribute and also can run other operations that you’ll learn more about them in its section.
Element getAttribute() Method Syntax:
Element getAttribute() Method Parameter
The method takes one argument and that is the attribute we want to get its associated value.
Element getAttribute() Method Return Value
The return value of this method is of type string and is equal to the value of the specified argument.
Note: if the specified attribute wasn’t declared in the target element, the return value could be either a null or an empty string.