What would be the best way to scan trough all the DOM, find any element that have text and wrap it in a span class? Thanx
To wrap all text nodes that contain something other than just whitespace:
$('body *').contents().filter(function() {
return (this.nodeType == 3) && this.nodeValue.match(/\S/);
}).wrap("")
To wrap all text nodes, including those that contain only whitespace:
$('body *').contents().filter(function() {
return (this.nodeType == 3) && this.nodeValue.length > 0;
}).wrap("")