JSFiddle - React, Tailwind, and code Playground
by no2don
JavaScript
function TryAdjustHTML(str){
var div = document.createElement('div');
div.innerHTML = str; // parses HTML to DOM elements
return div.innerHTML; // gets it back in a string form.
}
var strError="您好這是我的測試字串<div>ABCEF<br><a>FEGHI<img><br/></img><p>JKLMN</p></p></div>結束結束";
console.log(TryAdjustHTML(strError));
//您好這是我的測試字串<div>ABCEF<br><a>FEGHI<img><br><p>JKLMN</p><p></p></a></div><a>結束結束</a>