DOM을 확장하려고합니다. 나는 DIV 요소에서 "서브 클래스"appendChild()를 통해 어떤 JS 객체를 추가 할 수 있습니까?
객체에 대한 요구 사항이 무엇인지 객체의 프로토 타입 인하지 않을 것입니다 DOM 객체는 DOM에 삽입 할 그렇다면var Subclass = function() {}
Subclass.prototype = document.createElement('div');
Subclass.constructor = Subclass;
var obj = new Subclass();
var obj.innerHTML = 'test';
document.body.appendChild(obj); // Exception: Node cannot be inserted ... point in the hierarchy
?
관련 항목 : http://stackoverflow.com/questions/779880/in-javascript-can-you-extend-the-dom – Hamish