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

青灯夜游
Release: 2020-12-08 11:05:05
forward
4541 people have browsed it

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置为初始值
Copy after login

or this:

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

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这个下拉框进行重置刷新
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!