Ok, this is pretty simple, but if you've ever wished that the DOM exposed a
label property for any form element that had a label specified for it, well, you'll enjoy this.
!! UPDATED A FEW POSTS DOWN !!
Code:
function addLabelProperties( f )
{
var labels = f.getElementsByTagName( "label" );
for ( var i = 0; ( label = labels[i] ); i++ )
f.elements[label.htmlFor].label = label;
}
Just pass it a reference your form and voila! You now have
element.
label