[whatwg] getElementsByAttr

Sander html5 at zoid.nl
Fri Jul 6 12:24:25 PDT 2007


Hello,

I'm not sure if this has been proposed yet (can hardly believe it 
hasn't). But I couldn't find it in the specs so I just give it a go anyway.


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)

For attributes that can have more than one value (either seperated by 
spaces or commas) the value argument may be a space(/comma) seperated 
string or an array, similar to getElementsByClassName. If value is not 
defined of perhaps a wildcard ("*") the method should return all nodes 
that have the particular attribute, no matter what its value is.

The method overlaps with both getElementsByClassName, 
getElementsByTagName and getElementById, as these filter on attribute 
value as well, but it still adds extra opportunities.

cheers,
Sander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20070706/f64f0e48/attachment.htm>


More information about the whatwg mailing list