[jQuery] Selecting an element

[jQuery] Selecting an element

Hi,
I want to select a label element with a certain for attribute and either a certain validate attribute or a certain class. Something like this:
<label for="birthdate" validate="date" class="error">Please enter your correct birthdate</label>
<label for="birthdate" class="error $v(date)">Please enter your correct birthdate</label>
The script should try to find the label with the validate attribute first and try again with the class, if it can't find it. My current script does this:
var allErrorLabels = $("label.error[@for=birthdate]");
var errorLabel = allErrorLabels.filter("[@validate=date]");
if(errorLabel.size() == 0) {
errorLabel = allErrorLabels.filter("[@class*=date]");
}
errorLabel.show();
While that works with the validate attribute, it does not with the class. I wonder if the @foo*=value selector does not work or if I'm doing something wrong... Either way, I guess having the filter(Function) method added to jQuery would help in this case.
Any ideas?
-- Jörn
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/