What you want to do is add your function to any type prototypedocument.getElementById(id) .
In this case, it returns Element, therefore, to add your function to your prototype, you must write the following code.
Element.prototype.alrtHtml = function() {
alert(this.innerHTML)
}
source
share