More information about the Underscore mailing list

[_] jQuery selector confusion

Christian Wach needle at haystack.co.uk
Mon Nov 10 14:09:38 GMT 2008

On 10 Nov 2008, at 13:42, Pete Fairhurst wrote:

> $('form').each( function() {
>     var thisForm = $(this);
>     alert(thisForm.attr('id') + ' [' + $('thisForm >
> :input.required').length
>         + '/' + $('thisForm > *').length + ']');
> )};

This works for me:

$("form").each( function() {

   var tTotal = $(this).find("input").length;
   var tReq = $(this).find("input.required").length;
   alert( this.id + ' [' + tReq + '/' + tTotal + ']' );

});

Christian