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

时间:2015-10-05 05:09:45

标签: javascript ios objective-c wkwebview

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

e.g。

<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>

1 个答案:

答案 0 :(得分:0)

您可以尝试替换该元素的整个HTML内容。

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