Home>Article>Web Front-end> How to clear the selected state of bootstrap-select drop-down box?

How to clear the selected state of bootstrap-select drop-down box?

William Shakespeare
William Shakespeare forward
2020-12-07 17:47:42 4561browse

How to clear the selected state of bootstrap-select drop-down box?

Recommended related tutorials: "bootstrap Video Tutorial"

In PC-side projects, a large number of data list pages often appear, involving drop-down boxes Select filter conditions;

When using the bootstrap-select drop-down box, how can I click the reset button to clear the selected state of the drop-down box and restore it to the default state?

As shown in [Picture 1]

How to clear the selected state of bootstrap-select drop-down box?

When we choose to touch a condition

As shown in [Picture 2]

How to clear the selected state of bootstrap-select drop-down box?

At this time, click the reset button to return the state of [Figure 2] to [Figure 1]. We will use many methods, such as:

$("#loc_province_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#loc_city_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#loc_town_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_classification").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_industry").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_segmentation").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".customer_busi_status2").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#searchkey").attr("lang",'0');//将下拉列表属性lang置为初始值

or this:

document.getElementById("selectid").options.length = 0;

But we have found many methods that will not work for the bootstrap-select drop-down box. In fact, it is because bootstrap-select needs to refresh the current drop-down box on a clear basis and reload it

The code is as follows:

document.getElementById("searchPayState").options.selectedIndex = 0; //回到初始状态 $("#searchPayState").selectpicker('refresh');//对searchPayState这个下拉框进行重置刷新

The above code can solve the problem

For more programming-related knowledge, please visit:Programming Learning! !

The above is the detailed content of How to clear the selected state of bootstrap-select drop-down box?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete