I am looking for a method like document.getElementsByClassName()
, but just for attributes, that would also mean that document.getElementsByAttributeValue("class", "testclass")
would have the same output as document.getElementsByClassName("testclass")
.
It is not that easy since you cannot just add a function like this
document.getElementsByAttributeValue = function(){....};
because it has to work for document.getElementById("foo").getElementsByAttributeValue(...)
as well.
Needless to say, that I don't want a JQuery solution because there is no need for a giant library for just one function.