javascript - How to get "computed" text content of an HTML node (whitespace adjusted) -
i want able "computed" text content of html node, i.e. rendered browser.
example: consider following html:
<html> <body> <p>a b c d e f g <div>1</div><div>2</div> <a>3</a><a>4</a> <button onclick="javascript:alert(document.body.textcontent)">click me</button> </p> <pre>h i</pre> </body> </html>
here's picture of how above html renders in chrome 41.0.2272.101 m on windows 7:
is there simple, or relatively simple, way approximate text of <body>
node, example, in way captures fact html node boundaries "generate" whitespace (like boundary between <div>
nodes in above example)?
i approximation of text of <body>
node string like:
a b c d e f g 1 2 34 click me h
Comments
Post a Comment