Home  >  Article  >  Web Front-end  >  Introduction to the use of the indeterminate attribute of checkbox_HTML/Xhtml_Web page production

Introduction to the use of the indeterminate attribute of checkbox_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:40:081494browse

When we use the folder properties dialog box of Windows It is a gray state. In fact, this kind of uncertain CheckBox status can also be expressed in the Web.

In a Web page, we can use to get a CheckBox control. The most common form of this control is checked (marked with a tick) or unchecked state. We can use mouse clicks to easily switch between these two states. At the same time, 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 CheckBox can display:

The first and third are very common, and they can be set using HTML Yes, that is to say, we can determine the initial state of CheckBox through the 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. Instead, you can only use scripts to set its Indeterminate state.

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

Copy the code
The code is as follows:

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


Note: CheckBox’s indeterminate is an independent property. It has nothing to do with the checked and status values ​​of CheckBox, that is to say, it will only affect the appearance display of CheckBox. We can still use scripts to read the checked and status values ​​normally.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn