Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between attributes and Attribute in js

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report