I want to get the text of all elements. I am using this code here:
$('*').filter(function()
{
if(($(this).text().lenght>0)&&($(this).text().lenght<100))
{
return true;
}
else
{
return false;
}
}).each(function()
{
console.log($(this).text());
});
I have try to show only short text because .text() sometime returns html code but it is not working at all.
It’s much more simple:
$('body').text()gives you the whole text on the page.If you need to iterate over all the text nodes, see here: How do I select text nodes with jQuery?