What are the differences between attributes and Attribute in js
Editor to share with you what are the differences between attributes and Attribute in js, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The usage and difference of attributes and Attribute in js. Although the two things contained in the DOM element are not the same thing at all, they are closely related to each other, and it is really difficult to distinguish them without detailed experience. The concept of the four brothers is easy to understand and easy to use, so there are only a few points to pay attention to.
Several uses and meanings of Attribute
GetAttribute: gets the value of an attribute
SetAttribute: create a property and bind a value to the property at the same time
CreateAttribute: create only one attribute
RemoveAttribute: delete an attribute
GetAttributeNode: get a node as an object
SetAttributeNode: set up a node
RemoveAttributeNode: delete a node
How to use getAttribute
Vard=document.getElementById ("sss") .getAttribute ("value")
Console.log (d) / / aaa
The return value obtained by get is an attribute value.
How to use setAtribute
Vard=document.createAttribute ("good")
Document.getElementById ("sss") .setAttributeNode (d)
Alert (document.getElementById ("t") [xss_clean]) / / pop-up box
/ / an extra property is good; but no property value is set to it; therefore, it is empty.
These are all the contents of this article entitled "what are the differences between attributes and Attribute in js". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!