0
我在彈出式窗口中加載ajax請求。例如輸入:彈出式窗口中的非工作選擇器
<input id="target" type="text" value="123">
和文字:
test = $('#target').val();
console.log(test); //shows nothing
test2 = $('input#target').val();
console.log(test2); //shows 123
什麼可這種行爲的原因是什麼?輸入ID是唯一的。項目是寫在YII上,如果它很重要。
你確定你有一個ID爲target的元素嗎?如果你使用console.log($(「#target」)。length);'你會得到什麼? – mgraph
你可以用這個代碼$('[id = target]')。length來檢查是否有多個id爲target的元素。檢查並分享它在控制檯中記錄的內容。 –
檢查您沒有相同的id到多個元素,並在彈出加載後嘗試了控制檯 – thecodeparadox