adding a js method

Posted by Sorin Buturugeanu on Stack Overflow See other posts from Stack Overflow or by Sorin Buturugeanu
Published on 2011-01-02T10:20:03Z Indexed on 2011/01/02 10:53 UTC
Read the original article Hit count: 321

Hi!

I have a js function that is named getID which is basically return document.getElementById(id)

I want to make another function, getTag that would return getElementsByTagName.

The part that I can't seem to manage is that I want to be able to call them like this:

getID('myid').getTag('input') => so this would return all the input elements inside the element with the id myid

Thanks!

ps: getTag would also have to work if it's called by it's own, but then it would just return document.getElementsByTagName

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about object