try this:var f=$("form"); $("input,textarea",f).each(function(){ console.log($(this).attr("name")+'--'+$(this).val()); });
maybe this is what you want! On Mon, Nov 10, 2008 at 8:09 PM, Pete <[EMAIL PROTECTED]> wrote: > > The following doesn't work as expected and I don't understand why--can > someone explain, please? > > $('form').each( function() { > var thisForm = $(this); > alert(thisForm.attr('id') + ' [' + $('thisForm > > :input.required').length + '/' + $('thisForm > *').length + ']'); > )}; > > That I'm expecting the above to do is alert whenever a form is found > in the page, stating that form's ID value and how many of it's total > inputs are classed as 'required'. But all I get is e.g. "login [0/0]" > and I don't understand why. > > Can jQuery not use my thisForm object in this way? If not, how can I > store a reference and then call selections based on that object? > > Thanks in advance. I've been using jQuery for a little while now and > find it hugely useful, but stuff like this still utterly confuses me. > -- zhaobing Mobile:13824354001 Email:[EMAIL PROTECTED] <[EMAIL PROTECTED]>