我不明白一兩件事:爲什麼實例變量未定義?
var comein = document.getElementById("comein");
var enter = new Expand({ elem : comein });
function Expand (options) {
this._elem = options.elem;
console.log(this._elem); // i have a div element
}
Expand.prototype = {
check : function() {
var comInClassName = this._elem.className; // i have an error: this._elem is undefined
if (comInClassName == "open"){
this.close();
}
if (comInClassName == "close"){
this.open();
}
}
}
log_in.addEventListener("click", enter.check, false);
爲什麼我有原型法一個錯誤,如果在展開我有一個正常的元素?謝謝
到底是如何,你* *調用的 「檢查」 功能? – Pointy 2013-02-11 16:30:40
log_in.addEventListener(「click」,enter.check,false); – 2013-02-11 16:36:34