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 seven data types in JavaScript

Table of contents Preface: Detailed introduction:...

Layui implements sample code for multi-condition query

I recently made a file system and found that ther...

Vue global filter concepts, precautions and basic usage methods

Table of contents 1. The concept of filter 1. Cus...

VMWare15 installs Mac OS system (graphic tutorial)

Installation Environment WIN10 VMware Workstation...

Detailed tutorial on installing CentOS, JDK and Hadoop on VirtualBox

Table of contents 1. Prerequisites 1.1 Supported ...

Docker container time zone adjustment operation

How to check if the Docker container time zone is...

Teach you to connect to MySQL database using eclipse

Preface Since errors always occur, record the pro...

MySQL 5.7 installation and configuration method graphic tutorial

This tutorial shares the installation and configu...

Explanation of MySQL index types Normal, Unique and Full Text

MySQL's index types include normal index, uni...

Share some uncommon but useful JS techniques

Preface Programming languages ​​usually contain v...

Install OpenSSL on Windows and use OpenSSL to generate public and private keys

1. OpenSSL official website Official download add...

Vue3.0 adaptive operation of computers with different resolutions

First we need to install some dependencies npm i ...

A detailed introduction to deploying RabbitMQ environment with docker

Prerequisites: Docker is already installed 1. Fin...