javascript - Extending a DOM element with jQuery -


I want to extend a DOM element without expanding all of them. That is, I want a custom class with my custom methods and properties, but it can also be able to treat it as a div. E.g.

  MyClass = function () {this.foo = "waaa"; } MyClass.prototype.changeText = newtext {// If this extended $ (document.createElement ("div")) some // This is possible as html (newtext); } MyClass.prototype.alertFoo = function () {alert (this.foo); } Var m = new MyClass (); . $ ("Body") attached (m); M.changetext ();  

Is this possible?

You have a class of Jquery generated DIV element class to your class:

  Function Myclass () {this.foo = "waaa"; } MyClass.prototype = $ ('& lt; div / & gt;'); MyClass.prototype.changeText = Function (new text) {this.html (new text); } MyClass.prototype.alertFoo = function () {alert (this.foo); } Var m = new MyClass (); . $ ("Body") attached (m); M.changeText ('Appletree');  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -