0
以下功能在我的瀏覽器的控制檯窗口中拋出一個錯誤頁面加載時:引導3 jQuery的偏移JavaScript錯誤
function getRight() {
return ($(window).width() - ($('[data-toggle="popover"]').offset().left + $('[data-toggle="popover"]').outerWidth()))
}
錯誤:
Uncaught TypeError: Cannot read property 'left' of undefined
at getRight (application.js:12)
at HTMLDocument.<anonymous> (application.js:30)
at j (jquery.js:3099)
at Object.fireWith [as resolveWith] (jquery.js:3211)
at Function.ready (jquery.js:3417)
at HTMLDocument.I (jquery.js:3433)
getRight @ application.js:12
(anonymous) @ application.js:30
j @ jquery.js:3099
fireWith @ jquery.js:3211
ready @ jquery.js:3417
I @ jquery.js:3433
該頁面加載此jQuery的:
https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
你運行在DOM準備的代碼? – gaetanoM