指定したノードまたはその下にあるすべての Text ノードを検索し、ノードのテキスト コンテンツを抽出して連結し、単一の JavaScript 文字列として返す getText() という名前の関数を定義する必要があります。getText() では、呼び出されるのはアラートになります
私の体の内容は次のとおりです。
<body onload="getText()">
<div id="divText">
<h4>This is a heading!</h4>
<p>This is a paragraph.</p>
<p>And this is another paragraph.</p>
</div>
</body>