W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2007

[whatwg] getElementsByAttr

From: Sander <html5@zoid.nl>
Date: Fri, 06 Jul 2007 21:24:25 +0200
Message-ID: <468E96E9.8050203@zoid.nl>
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>
Received on Friday, 6 July 2007 12:24:25 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:36 UTC