You can use .each to iterate over all elememnts:
$('*').each(function(){
if($(this).text())
{
$(this).wrapInner('');
}
})
I didn't test that piece of code but it is quite simple. All you need to learn about is .each, wrapInner and * selector. jQuery docs is pretty helpful here.