In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces what is the difference between name, id and class in HTML, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.
On a page, there are many controls (elements or labels). In order to manipulate these tags more conveniently, it is necessary to identify these tags with an identity card.
The required attributes are: name, id, class
1. Name
Specifies the name of the label.
1.1 format:
1.2 Application scenario
① form form: name can be used as the variable name passed to the server form list; for example, the name passed to the server above is: value of username='text'
② input type='radio' radio tags: when the name of several radio tags is set to the same value, the radio operation will be performed.
The code is as follows:
Male
Female
③ quickly gets a set of tags with the same name: get tags with the same name, and perform operations together, such as changing attributes, registering events, etc.
[code]
Function changtxtcolor () {
Var txts = document.getElementsByName ('txtcolor'); / / get the tags of all name=txtcolor
For (var I = 0; I < txts.length; iTunes +) {/ / cycle through the tag and change the background color to red
Txts [I] .style.backgroundColor = 'red'
}
}
1.3 Features
The value of the name property is not unique in the current page page.
2. Id
Specifies the unique identity of the label.
2.1 format:
2.2 Application scenarios:
① quickly acquires the label object according to the unique id number provided. Such as: document.getElementById (id)
The value ② is used to act as the for attribute of the label tag: example: user name:, indicating that when the label tag is clicked, the id gets focus for the userid tag.
2.3 characteristics
The value of the id attribute should be unique on the current page page.
3. Class
Specifies the class name of the label.
3.1 format:
3.2 Application scenarios:
① CSS operation, put some specific styles into a class class, you need this style of label, you can add this class.
3.3 Features:
You can put multiple classes in a class attribute, but they must be separated by spaces; for example, class='btnsubmit btnopen'
Thank you for reading this article carefully. I hope the article "what's the difference between name, id and class in HTML" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.