Introduction to the use of the indeterminate property of the checkbox

Introduction to the use of the indeterminate property of the checkbox
When we use the folder properties dialog box in Windows XP, we will find that the Read-only and Hidden options in the folder's Attributes category are sometimes not completely checked or unchecked, but often a state in which they are checked but the background is gray. In fact, this uncertain CheckBox state can also be expressed on the Web.

In a web page, we can use <input id="chkb" type="CheckBox"> to get a CheckBox control. The most common form of this control is checked (with a checkmark) or unchecked. We can easily switch between these two states by clicking the mouse, and we can also use scripting languages ​​to change their states, such as using JavaScript scripts:

Copy code
The code is as follows:

chkb.checked = true; or chkb.checked = false;

The following figure shows the three states that a CheckBox can display:

The first and third ones are very common, and they can be set using HTML, that is, we can determine the initial state of the CheckBox through an attribute of an HTML element called checked. Although the Indeterminate state we are talking about here has been supported since IE4.0, there is no HTML element attribute to set its value, and the Indeterminate state can only be set using scripts.

For example, using JavaScript scripts (indeterminate is false by default):

Copy code
The code is as follows:

chkb.indeterminate = true; or chkb.indeterminate = false;


Note : indeterminate of CheckBox is an independent property and has nothing to do with the values ​​of checked and status of CheckBox. That is to say, it only affects the appearance of CheckBox. We can still use scripts to read the values ​​of checked and status normally.

<<:  What kinds of MYSQL connection queries do you know?

>>:  Detailed explanation of the hierarchical relationship problem caused by CSS positioning

Recommend

Detailed explanation of the order of JS object traversal

Some of you may have heard that the order of trav...

How to connect to docker server using ssh

When I first came into contact with docker, I was...

Example of implementing todo application with Vue

background First of all, I would like to state th...

MySql Installer 8.0.18 Visual Installation Tutorial with Pictures and Text

Table of contents 1. MySQL 8.0.18 installation 2....

Linux RabbitMQ cluster construction process diagram

1. Overall steps At the beginning, we introduced ...

How to install JDK 13 in Linux environment using compressed package

What is JDK? Well, if you don't know this que...

Detailed explanation of the use of JavaScript functions

Table of contents 1. Declare a function 2. Callin...

How to fix some content in a fixed position when scrolling HTML page

This article mainly introduces how some content i...

Solution to the problem of MySQL deleting and inserting data very slowly

When a company developer executes an insert state...

JavaScript dynamically generates a table with row deletion function

This article example shares the specific code of ...

Vue event's $event parameter = event value case

template <el-table :data="dataList"&...