i i tryed to explore jQuery because its build from prototypes so i made script like that
-
var TaderDOM = window.TaderDOM = window.$ = function(element) {
-
return new TaderDOM.fn.init(element);
-
};
-
-
TaderDOM.fn = {
-
init: function(element) {
-
return document.getElementById(element);
-
},
-
html: function() {
-
return "working";
-
}
-
};
-
TaderDOM.fn.init.prorotype = TaderDOM.fn;
-
when i call $(element).html(); it should return me working but it don't why?
because new TaderDOM.fn.init(element) returns an object, the element.
the html() function you want is one dot to the left, on TaderDOM.fn.
other than being stored in the same object, init and html bear no inherit relation ship to each other.
you are essentially just pointing to the function init as any other variable.
you could add .html() to, say, Object's prototype (some will cringe), or create a constructor function, and add .html() to it's prototype.