For example for this.parentNode I would like to just write this.p or instead of
document.getElementById('someid') just write document.g('someid'). Of course that are simple examples, I just want to know what is the correct way to do it.
(I know I can use jQuery or Prototype, but I’d like to learn how it is really done in JS)
Although you can prototype on the
HTMLElementin many browsers – Internet Explorer (6,7,8) is NOT one of them. AFAIK, IE9 does support this (though I haven’t tested it).For browsers that do handle it, you can do: