How to recursively parse data with jQuery

I have jQuery code like the following (which works fine):

$('[RptrRowEnableAutoHeight=""True""]').each(function () { var ch = 10; $(this).children().each(function(){ch += $(this).height();}); $(this).height(ch); }); 

The above only works for immediate children of the root element. How can I achieve the same for all nested children.

This is a special case for us, since the layout was developed using absolute positioning (almost everywhere). At the moment, we cannot change the whole layout using the stream layout.

In a simple form, I would like all the (container) controls to expand (their height / width) automatically to provide their children accordingly (without any scroll / hide bars).

thanks

+4
source share
1 answer

You can use $(this).find('*').each(...

+17
source

Source: https://habr.com/ru/post/1336046/


All Articles