0
我有幾個選擇,讓衆將選擇他們的球員jQuery的焦點佔位選擇/ VAL(「」)
$('.select_role').on('focus',function(){
console.log("Test");
})
$('.select_role').on('change',function(e){
$.ajax({
url : './tournaments/hub/save_roster.php',
type :'POST',
data : {
role_id : $(this).data('role'),
tournament_id : '<?php echo $tournament_id;?>',
team_id : '<?php echo $team_id;?>',
user_id : $(this).val()
},
success : function(res){
res = jQuery.parseJSON(res);
if(res.result == 0){
toastr.warning(res.resp);
}
if(res.result == 1){
toastr.success(res.resp);
}
}
})
})
在從我的服務器腳本錯誤消息的位置,選擇要恢復到用戶改變之前的前一個val。
出於某種原因,我無法專注於select元素的工作,所以我無法讓佔位符恢復。
回到原來也不可能利用這樣一行
var ele = $(this)
ele.val("");
的選擇本身就具有價值=「0」作爲一個選項
我在做什麼錯?