Edit: I'm closing this question as a duplicate of this.
I can't wrap my mind around this simple concept. I want to create a class, say:
function InputExt() {
...
}
And then I want to do something like this:
InputExt.prototype = document.createElement('input');
But this would only give my InputExt
methods and properties of a Node
, while InputExt
instances will not behave as a Node
, nor as a HTMLInputElement
.
How can I achieve the behavior below?
InputExt.prototype.info = function() {
console.log(this);
}
var element = document.body.appendChild(new InputExt());
element.info();