[jQuery] Getting the nearest label

[jQuery] Getting the nearest label


Hi, i'm looking in API/1.1.2/DOM/Traversing section of the doc for what
I'm tryng to do...
I think siblings() could be my function, but don't know how to use it..
I've a form like this:
<label for="test"></label>
<input id="test">
<label for="test"></label>
<input id="test2>
After the submit I do some server-side controls, then if there are
errors I reload the page and in a hidden field I put the ids of the
wrong fields.
Then in document ready I want to load those id and add a class to
nearest(prev) label to change the color.
For example if the hidden field contains "test" I want to change the
color of the first label.
There's a way without changing the markup?
Thank you