在WKWebView中替换DIV标记的多行文本内容?

问题描述:

WKWebView上使用evaluateJavaScript:completionHandler:,我可以替换DIV元素中的单行文本,但是如何替换多行innerHTML?在WKWebView中替换DIV标记的多行文本内容?

例如

<div id="MyContent"><hr>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<br><p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p> <hr></div>

<div id="MyContent">Arbitrary multi-line html goes here to replace above inner html...</div>

你可以尝试更换元件整个HTML内容。

document.getElementById("MyContent").innerHTML = "New<br />Text";