To check if an HTML element has a specific attribute, you can use the hasAttribute() method . This method returns true if the specified attribute exists, otherwise it returns false . The hasAttribute() method also works for the HTML5 data-* attributes.10 Ağu 2020