jquery - Count child elements of "this" -
i have following html structure , want count number of input within outer foo - there might several instances of foo on 1 page, therefore want count within each instance
<div class="foo"> <div> <input type="text...> <label></label> <input type="text...> <label></label> </div> </div> here's i'm trying, of course fails because this abject , div , input not
$(".foo").each( function () { console.log( $(this > div > input).length ); }) is there way this?
use:
$(".foo").each( function () { console.log( $(this).find('> div > input').length ); });
Comments
Post a Comment