제목을 사용하면 다음과 같은 오류가 발생합니다.이 시나리오에서 test.elem이 정의되지 않은 이유는 무엇입니까?
var test = {
elem : undefined,
init : function() { console.log("test.init() fired");
elem = $("#id");
console.log("elem assigned to jQuery object");
elem.click(function() { console.log("elem clicked"); });
console.log("elem click handler created");
}
};
test.init();
test.elem.click();
이해가 안됩니다. test.init()
를 실행하여 test.elem
의 값을 할당하면 나중에 액세스하려고 할 때 정의되지 않은 이유는 무엇입니까?
'this.elem = $ ("# id를") '등 – mVChr
을 난 그런 백치. 10 시간이 지나면 작업을 마칠 때가되었습니다. –