Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the differences between attributes and Attribute in js

Shulou Source: shulou.com Published: 2022-06-03 05:15:42 11月15日 Update

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!

Tags: Attributes articles nodes content one not good not much things two methods of use elements brothers meanings things most objects methods more concepts knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Docker Apple MariaDB