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

How to install pip package in Linux

1. Download the pip installation package accordin...

A brief discussion on the mysql execution process and sequence

Table of contents 1:mysql execution process 1.1: ...

A complete list of commonly used Linux commands (recommended collection)

Table of contents 1. System Information 2. Shutdo...

CSS uses calc() to obtain the current visible screen height

First, let's take a look at the relative leng...

Detailed explanation of where the images pulled by docker are stored

The commands pulled by docker are stored in the /...

Installation and configuration of mysql 8.0.15 under Centos7

This article shares with you the installation and...

Setting up a proxy server using nginx

Nginx can use its reverse proxy function to imple...

Use of Linux date command

1. Command Introduction The date command is used ...

A brief summary of vue keep-alive

1. Function Mainly used to preserve component sta...

Detailed explanation of writing and using Makefile under Linux

Table of contents Makefile Makefile naming and ru...

Several ways to implement 0ms delay timer in js

Table of contents queueMicrotask async/await Mess...