One of the strengths of object oriented programming is object methods. They tighten code and make design solutions much easier. JavaScript makes it easy to extend core object constructors and custom object constructors—like classes but JavaScript uses a prototype mechanism and not classes—through the constructor's prototype property. A good example of this is the Extended Date Methods How-to. The advantage to extending the constructor is that each instance inherits the new methods; otherwise, code would have to assign the methods to each instance.
It is really useful to be able to extend HTML elements with custom methods when coding Web 2.0 application and DHTML. This tutorial will show you how to do just that.
Well, the constructors for JavaScript representations of HTML elements are extended. And, of course, there is the IE way and non-IE way. The next three pages cover the techniques. First the non-IE way followed by the IE way and finally cross browser code combining both techniques is presented.