Buzzterrier schrieb:
I want to get all labels in a form, and then access their "for"
attribute to link it to the field.

I thought that $("label") would give me an array of all label elements
that I could loop through and get the "for" value. But this does not
work and I know I am missing something fundamental to Jquery.

If I do:

$("label").attr("for");

It gives me the first label in the fieldset, which is confusing.


But just doing $("label") should give you the array.
You probably have to do it like this (as .attr() just returns the value of the attribute):

$("label").each(function(){
        foo = $(this).attr("for");
});

Cheers,
/rw

Reply via email to