> $('#formid>input').each(function(){ > if($(this).attr('id')!='') alert($(this).attr('value'); //fetch id if > not blank ang show value > > }); > > the code inside this function does not run if the form is rendered > this way: > > <form> > <div id='tabs" > > <ul>...</ul> > <div id='tab1"> > <input type='text' id='fname' /> > </div> > </div> > </form> > > but if it is rendered in a simplier way like this, it works: > <form> > <input type='text' id='fname' /> > </form> >
Your selector is wrong: $('#formid>input'); That says: find input elements that are direct children of #formid. What you want is this: $('#formid input'); which will find input elements that exist anywhere in the DOM beneath #formid. http://www.w3.org/TR/CSS21/selector.html