我正在使用这个库:https://developer.snapappointments.com/bootstrap-select/但是我在选择时无法改变它的行为。例如
<select class="selectpicker">
<option>Mustard</option>
<option>Ketchup</option>
<option>Barbecue</option>
</select>
其中selectpicker
是创建此结构的关键:
<button type="button" class="btn dropdown-toggle btn-new" data-toggle="dropdown" role="button" data-id="blabla" title="Mustard" aria-expanded="true">
<div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner">Mustard</div></div>
</div>
</button>
所以,主要是,库在select上创建一个按钮(存在但隐藏)。我想要的是,当我选择列表中的一个项目时,边框颜色(按钮而不是选择)改变颜色在#BF69B2
我尝试过这样:
document.getElementsByClassName("btn dropdown-toggle btn-default")[0].style.borderColor = "#BF69B2";
但没有成功。任何的想法?
您正在尝试使用类qazxsw poi检索元素,但在模板中您有另一个类:qazxsw poi。
只是改变
btn dropdown-toggle btn-default
至
btn dropdown-toggle btn-new