原因是:需要用prop代替attr
那么,什么時(shí)候使用attr(),什么時(shí)候使用prop()?
http://wenzhixin.net.cn/2013/05/24/jquery_attr_prop 有介紹
根據(jù)官方的建議:具有 true 和 false 兩個(gè)屬性的屬性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr()

image.png
錯(cuò)誤的代碼:
function selectedPostion(target, index) {
target.find('option').attr("selected", false);
target.find([value=${index}]).attr('selected', true);
}
改正后:
function selectedPostion(target, index) {
target.find('option').prop("selected", false);
target.find([value=${index}]).prop('selected', true);
}