我要创造我自己的DOM对象类型:如何正确委托对象?
var Obj = function(id) {
this.id = id;
this.constructor.prototype = document.getElementById(id);
};
var x = new Obj("a_div"); //Success
alert(x.type); //Successfully alert "div"
x.innerHTML = "TEST"; //This does not update the actual div html on the page!!!
我想任何函数调用该对象将被转发到实际的DOM对象。我怎样才能做到这一点?
这似乎并没有工作,你描述('div'不惊动)的方式: –
你想扩展在div对象http://jsfiddle.net/y3Je3/1/?我不认为你可以。 –
@RocketHazmat我想委托它.. – texasbruce