Unescape HTML entities containing newline in Javascript?
问题 If you have a string containing HTML entities and want to unescape it, this solution (or variants thereof) is suggested multiple times: function htmlDecode(input){ var e = document.createElement('div'); e.innerHTML = input; return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; } htmlDecode("<img src='myimage.jpg'>"); // returns "<img src='myimage.jpg'>" (See, for example, this answer: https://stackoverflow.com/a/1912522/1199564) This works fine as long as the string does not