In Javascript, can you extend the DOM?

I found the answer just as I was writing the question, but thought I’d post anyway to share the info.

The object you need to extend is Element.prototype.

Element.prototype.getMyId = function() {
    return this.id;
};

Leave a Comment