Javascript find text on page

前端 未结 5 550
广开言路
广开言路 2021-01-14 22:13

I need to run a search and replace on HTML similar to the following... I need to have \"Find Next\" \"Replace\" and \"Replace All\" options.... the trick is that I need to r

5条回答
  •  无人共我
    2021-01-14 22:37

    If you must search/replace the html, then use the innerHTML property:

    document.getElementById("sheet").innerHTML
    

    But be aware that the browser keeps the DOM in memory as a tree, not as HTML. It only reads HTML to construct the DOM. So you may find element-wise changes are faster.

提交回复
热议问题