CORRECTION: the IF statement needs a == instead of the =.
if($form.find('input[name=id]').length == 0) {...} On May 19, 9:34 am, Brian Schilt <[EMAIL PROTECTED]> wrote: > You could do something like this: > > $('form').each(function(){ > var $form = $(this); > if($form.find('input[name=id]').length = 0) { > //create new input. > $("<input type='text' value='' name='id'/>").appendTo($form); > } > > }); > > This will check each form on the page for an input field with an > attribute of name=id. If it doesn't exist, then it creates on and > appends it to the end of the form. > > On May 19, 8:42 am, tonous <[EMAIL PROTECTED]> wrote: > > > Hello I'm trying to solve this - > > I have several forms on page and need to be sure that all of them have > > input id, some of them already have it some of them not, how to get > > the form where I need to add an input? > > > I tried to get the forms which have this input > > $(document).ready(function() { > > $("form [EMAIL PROTECTED]'id']").each(function(j){ > > alert($(this).attr("name")+ $(this).attr("value")); > > }); > > > }); > > > but I need somthing like this > > $(form).each(function(){ > > /* $("input there is no id").each(function(){create input})*/ > > > }) > > > thanks for help > > Radek