[whatwg] getElementsByAttr

Sander html5 at zoid.nl
Fri Jul 6 13:05:26 PDT 2007

Charles McCathieNevile schreef:
> On Fri, 06 Jul 2007 21:24:25 +0200, Sander <html5 at zoid.nl> wrote:
>> I'd like to see a getElementsByAttr method. It would be quite similar as
>> the getElementsByClassName method but with an extra argument:
>> getElementsByAttr(attribute_name, value)
> The W3C's WebAPI group is specifying a selectors API (the spec was 
> mostly put together by Anne van Kesteren, and now Lachy Hunt is 
> finishing it up), which allows you to do this. The longest running 
> issue is the name of the methods (hopefully we have some closure on 
> that now...) but it lets you do something like
> methodName("*[lang|=en]") that returns whatever matches that selector....
> the current editor's draft can be found at 
> http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html 

Aha, a CSS selector kind of filtering. That's nice as a lot of authors 
will be familiar with that type of notation.

I haven't read the whole draft yet so maybe it's in there, but can you, 
or anyone else, explain why there is both a selectElement and a 
selectAllElements method? I'd say just a selectElements method would be 
enough, but perhaps I'm missing something obvious here.

Anyway, I really hope this kind of function will be added.


More information about the whatwg mailing list