Is there some method in jQuery to get all nested children? I mean complete collection from all nested levels so that I do not need to call function recursively.
Here is my function
$.fn.extend({
compressElementsWidth: function() {
var range = { min: 9999, max: 0 };
console.log( $(this).contents() );
$(this).contents().filter(
function() {
if (this.nodeType == 3 )
return this.nodeValue && this.nodeValue.replace(/\s{1,6}/,'') ? $(this) : null;
else
return this.nodeName.match(/IMG|A|GROUP|FIELDSET|INPUT|SELECT|TEXTAREA|BUTTON|SUBMIT/) ? $(this) : null;
}).each(function(e) {
var left = $(this).position();
if (p.left < range.min )
range.min = p.left;
var right = p.left + $(this).width;
if ( right > range.max )
range.max = right;
});
var max_width = range.max - range.min;
$(this).contents().filter(
function()
{
if (this.nodeType == 3 )
return this.nodeValue && this.nodeValue.replace(/\s{1,6}/,'') ? $(this) : null;
else
return this.nodeName.match(/IMG|A|GROUP|FIELDSET|INPUT|SELECT|TEXTAREA|BUTTON|SUBMIT/) ? $(this) : null;
}).each(function(e) {
$(this).css("max-width:", max_width );
});
}
});
window.onload = function() {
$("div.column-right-outer").compressElementsWidth();
};
So I need to get all elements inside the div.column-right-outer. You can test this code on this page, just save it and include jQuery and the code above. For example in the Blog Archive, there is huge list of links and I need to get all the links and all the visible text which is under the right column. If there would be images or form elements I need them in the collection too.
Results of recursion and $(node).find("*") are about 10.000-16.000 and extremely slow performance.

