0
자바 스크립트에서 OOP를 배우기위한 간단한 프로그램을 만들었습니다. 미리 정의 된 문자열 문만을 출력합니다. 여기서 문제는 프로그램이 텍스트 노드를 "출력 div"에 직접 바인딩하는 반면 은 이전 명령을 각각의 "p"요소에 추가하는 것을 무시한다는 것입니다.document.createElement() 무시됨
Student.prototype.sayHello = function()
{
var responseString = document.createTextNode("Hello, I've been waiting here for you. Student.");
return document.createElement("p").appendChild(responseString);
}
Student.prototype.sayGoodBye = function()
{
var responseString = document.createTextNode("tchau");
return document.createElement("p").appendChild(responseString);
}
var student = new Student();
document.getElementById("output").appendChild(student.sayHello());
document.getElementById("output").appendChild(student.walk());
document.getElementById("output").appendChild(student.sayGoodBye());