Document.getElementsBySelector

I’ve finally got around to implementing an idea I had ages ago: document.getElementsBySelector:

http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector

It’s a javascript function that allows you to grab an array of elements based on a CSS selector - for example, document.getElementsBySelector(‘div#main p a.external’) returns all links with class=“external” that are inside paragraphs inside a div id=“main”.

I’ve tested it on Phoenix and IE6 and it works fine - feedback on other browsers it works with would be great.

Cheers,

Simon

Cool. Can’t say I’ve ever needed it, but cool :tup:

Why not simply select the stylesheet rules using the DOM ? It’s great that you have this idea and it works, etc.

But I can’t see a use for it personally though ? Maybe you could now implement it into an API so people cannot access a CSS selector directly ?

You might want to consider Set and Get object methods for your API instead…