textContentメソッド

参考サイトMDNtextContent は Node のプロパティ

------------------------ HTMLのコード 実は次のようになってます -----------------------------
<div id="divA">This is <span>some</span> text!</div>
------------------------ javascriptは次のようになってます。 ------------------------------
                                // ... textContent を使用して、要素のテキストの内容を取得することができます。
let text = document.getElementById('divA').textContent;

                               //... また、要素のテキストを設定します。
document.getElementById('divA').textContent = 'This text is different!';

                                                     // divA の HTML は次のようになります。替わる!!
                                                     // <div id="divA">This text is different!</div>

結果

This is some text!