If better you mean fewer details, this is equivalent to functionally
parent.find('*').each(function(){ if($(this).is("input")) { var type = $(this).attr('type'); if(type =="text")
Note that there is no need for recursion, because
parent.find('*')
uses * (all-selector) . This will allow you to get all the children and nested children.
Update
To increase productivity, you can reorganize higher
parent.find('input[type="text"]').each(function(){ var type = $(this).attr('type');
This will result in nesting all nested input elements, so you donβt even have to check
if($(this).is("input"))
source share