Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  80] [ 3]  / answers: 1 / hits: 25953  / 14 Years ago, sat, november 20, 2010, 12:00:00

I am building Chrome extension which at some point should determine current page language. In order to do that, my plan is to extract text content of the page (or at least a part of it) and pass it to translation api. However I couldn't find any strait forward way to just get all textNodes of the document.



There is a backup plan which is to recursively analyze $('body').contents() until there is enough text content, but it feels a bit flaky. Perhaps there is a better way?






Note: Chrome extensions api allows your script to access user page dom as if it was the part of it.


More From » jquery

 Answers
419

Using the jQuery text() method



$('body').text()

[#94891] Thursday, November 18, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danalexc

Total Points: 114
Total Questions: 119
Total Answers: 103

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
;