1
我只在嘗試通過IE 11執行mvc 4應用程序時出現跟隨錯誤,但它在谷歌瀏覽器中正常工作。0x800a138f - JavaScript運行時錯誤:無法獲取未定義或空引用jquery的屬性'setAttribute'
0x800a138f - JavaScript runtime error: Unable to get property 'setAttribute' of undefined or null reference jquery
以下是發生錯誤的代碼片段。但是我可以確保登錄屏幕上沒有數據訪問器對象。什麼一定是導致問題?
if (!Modernizr.inputtypes.date) {
$(function() {
$("input[type='date']")
.datepicker()
.get(0)
.setAttribute("type", "text");
})
}
你爲什麼在if語句中調用'document ready'?第二個:使用這個'$(「input [type ='date']」)。attr(「type」,「text」)''或'$(「input [type ='date']」)。 prop(「type」,「text」)' – Pavlo
此外,只是在jsfiddle中檢查了你的代碼,它工作正常(沒有if語句,因爲我沒有定義Modernizr對象)。 – Pavlo
添加prop或attr與以下消息沒有任何區別:0x800a138f - JavaScript運行時錯誤:無法獲取未定義或空引用的屬性'prop' – ecasper