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;
};
More Related Contents:
- Trying to use Javascript to add new li element to my ordered list, anyone know why this code isn’t working?
- How to make JavaScript execute after page load?
- How do I programmatically set the value of a select box element using JavaScript?
- How to correctly iterate through getElementsByClassName
- Appending HTML string to the DOM
- Difference between Node object and Element object?
- HTML “overlay” which allows clicks to fall through to elements behind it [duplicate]
- Finding element’s position relative to the document
- JavaScript get element by name
- Using this inside an event handler
- How to scroll down with Phantomjs to load dynamic content
- Difference between Element.value and Element.getAttribute(“value”)
- Native JS equivalent to jQuery delegation
- Are event handlers in JavaScript called in order?
- HTML DOM: Which events do not bubble?
- scrollIntoView Scrolls just too far
- In JavaScript, what is the best way to convert a NodeList to an array?
- How to avoid no-param-reassign when setting a property on a DOM object
- How to clone or re-dispatch DOM events?
- How to set DOM element as first child?
- window.getSelection() gives me the selected text, but I want the HTML
- Is there a flexible way to modify the contents of an editable element?
- a way to check validity of HTML5 forms?
- Open new window without focus on it [duplicate]
- window.getSelection return html [duplicate]
- How to swap DOM child nodes in JavaScript?
- Is it bad practice to add properties to DOM nodes?
- Adding Event Listeners on Elements – Javascript
- Maintain cursor position in contenteditable div [duplicate]
- Why is document.getElementById(‘tableId’).innerHTML not working in IE8?