2016-03-15 133 views
1

我試圖在select2中選擇更改時將焦點移到下一個元素上。但我不能那樣做。 爲什麼我的焦點不會轉移到下一個領域?如何將焦點移到select2中的下一個元素上

HTML代碼

<form> 
<select autofocus id="select2" name="entry_id"> 
    <option value="0">00000000</option> 
    <option value="1">11111111</option> 
</select> 
<input type="text" name="entry_id2" class="entry2"> 

JavaScript代碼

$("#select2").select2(); 
$("#select2").on("change", function() { 
$(this).closet("form").find(".entry2").focus(); 
}); 

示例頁面:https://jsfiddle.net/39wk54zk/

回答

0

這可能不是100%的修復,但我已經在這片發現的代碼,你寫了.closet而不是.closest:

$(this).closet("form").find(".entry2").focus(); 

我覺得應該是:

$(this).closest("form").find(".entry2").focus(); 

我沒有測試過,但是這可能是你的問題的一部分。

相關問題