In a page, there are many controls (elements or tags). In order to operate these tags more conveniently, they need to be marked with an identity card. The attributes required are: name, id, class 1. name Specify a name for the tag. 1.1 Format: <input type="text" name="username" /> 1.2 Application Scenarios ①form: name can be used as the variable name of the form list transferred to the server; for example, the name transferred to the server above is: username='value of text'; ②Input type='radio' radio tag: When the name of several radio tags is set to the same value, a radio selection operation will be performed. Copy code The code is as follows:<input type="radio" name='sex'/>Male <input type="radio" name='sex'/>Female③Quickly obtain a group of tags with the same name: obtain 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 all tags with name=txtcolor for (var i = 0; i < txts.length; i++) { //Loop through the tags and change the background color to red txts[i].style.backgroundColor = 'red'; } } 1.3 Features The value of the name attribute is not unique in the current page. 2. id Specifies the unique identifier of a tag. 2.1 Format: <input type=password id="userpwd" /> 2.2 Application scenarios: ①Quickly obtain the tag object based on the unique ID number provided. For example: document.getElementById(id) ② Used as the value of the for attribute of the label tag: Example: <label for='userid'>Username: </label>, which means that when this label tag is clicked, the label with id userid gets the focus. 2.3 Features The value of the id attribute must be unique on the current page. 3. class Specifies the class name of the tag. 3.1 Format: <input type=button class="btnsubmit" /> 3.2 Application scenarios: ①CSS operation, put some specific styles into a class class, and add this class if you need tags of this style. 3.3 Features: You can put multiple classes in one class attribute, but they must be separated by spaces; for example: class='btnsubmit btnopen' |
<<: MySQL data aggregation and grouping
>>: Detailed steps to expand LVM disk in Linux
1. DOCTYPE is indispensable. The browser determin...
<br />Related article: Analysis of Facebook&...
The mysql explain command is used to show how MyS...
When the user's home directory becomes larger...
Table of contents Introduction to stored procedur...
It’s great to use CSS to realize various graphics...
MYSQL officially provides an Installer method to ...
In the previous article, we have implemented loca...
1. Delete the original mariadb, otherwise mysql c...
count(*) accomplish 1. MyISAM: Stores the total n...
XML/HTML CodeCopy content to clipboard < div s...
Copy code The code is as follows: <style type=...
1. Business Scenario I have been doing developmen...
This article shares the specific code of JavaScri...