【发布时间】:2016-05-22 19:32:07
【问题描述】:
我正在使用引导选择插件 (http://silviomoreto.github.io/),并且我正在处理更改事件“changed.bs.select”以捕获任何选择更改。根据https://silviomoreto.github.io/bootstrap-select/options/ 的文档,“此事件在选择的值更改后触发。它通过事件、clickedIndex、newValue、oldValue。”
我想了解 newValue 和 oldValue 究竟代表什么。因为总是新值为真而旧值为假的情况。
这里有一个小提琴来说明我的观点。
https://jsfiddle.net/muojdbh9/
HTML
<select class="selectpicker">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
<div class="res">
Waiting for a change event
</div>
jQuery
$(".selectpicker").on('changed.bs.select', function (event, clickedIndex, newValue, oldValue) {
$("div.res").html("newValue: " + newValue + "<BR>oldValue: " + oldValue);
});
【问题讨论】:
标签: jquery twitter-bootstrap bootstrap-select