我想不通,爲什麼我不能得到的「這個」的屬性在下面的代碼:類型錯誤:this.getAttribute不是一個函數 - JavaScript的
var Deferjs = {
init: function(){
if(document.getElementById('js-currentPage')!=null){
var file = this.getAttribute('data-page');
Deferjs.LoadJs(file);
}
},
LoadJs:function(file){
alert("ok");
}
}
Deferjs.init();
但是如果我改變 this.getAttribute(」數據頁');到的document.getElementById( 'JS-當前頁')。它的getAttribute工作
請幫助我瞭解上述
THX
我想'this'不包含你所想的if語句,用'的document.getElementById(「JS-當前頁」)替換它'應該解決您的問題 – BeNdErR 2015-04-03 10:55:36
'this'是不是指'document.getElementById('js-currentPage')' – ozil 2015-04-03 10:57:05
你覺得'this'點 – semirturgay 2015-04-03 10:57:13