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
Table of contents 1. Introduction: 2. Docker: 1 C...
Step 1: Use Notepad to open the "my.ini"...
Let's start with a description of the problem...
Using depends_on to sort containers does not perf...
Why optimize: With the launch of the actual proje...
Table of contents 1. Introduction 2. Analysis of ...
1. Introduction to Layer 4 Load Balancing What is...
1. Title HTML defines six <h> tags: <h1&...
The “Cancel” button is not part of the necessary ...
This post introduces a set of free Photoshop wire...
Problem Description When using Windows Server 201...
1. Use docker images to view all the image files ...
When we edit a layout, we usually use horizontal ...
In this article, we will need to learn how to vie...
This article example shares the specific code of ...