Properties can usually be changed, added, and deleted, but some are read only. var elem = document.getElementById("button"); As we mentioned, it is automatically converted to lowercase letters. It automatically converts kebab-style attributes in HTML, like data-this-little-piggy, to camelCase style in JavaScript, like dataThisLittlePiggy. In this topic, we are going to learn about the SetAttribute JavaScript.
Properties can … In scripts.js This setAttribute JavaScript method is used to add a specified attribute to an element, giving the attribute a certain value. The getAttribute() method of the Element interface returns the value of a specified attribute on the element. Properties are the values associated with a JavaScript object. setAttribute() Method: This method adds the defined attribute to an element, and gives it the defined value. SQL
Any attribute on any element whose attribute name starts with data-is a data attribute. The attributeValue should contain the value you want to assign to attributes. element.style.backgroundColor = "yellow"; HTML