On May 4, 8:18 am, Kristian <kmand...@gmail.com> wrote:
> I have the following HTML within a form
>
> I suppose I should somehow loop through all the labels, and for each
> find the next input. Then make a selection of this union and apply a
> wrapAll('<div class='field'>)
>
> But how exactly do I do this using jQuery manipulators?
>
> Kristian

$('#myform label').each(function(){
     $(this).add( $('#'+$(this).attr('for') ).wrapAll('<div
class="field" />');
});

or

$('#myform label').each(function(){
     $(this).next('input').andSelf().wrapAll('<div class="field" />');
});

http://docs.jquery.com/Traversing

-- ricardo

Reply via email to