var target = '<p><img alt=\"\" src=\"upfiles\/54591303758197437.jpg\" \/><\/p>'
$(function(){
var x=$('<div/>').text(target).html();
alert(x);
document.write(x)
});
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
I show the escaped string contained html tags and write in webpage.
The escaped string in the alert window is right, but after closing the alert window you can ony see (screenshot):
<p><img alt="" src="upfiles/54591303758197437.jpg" /></p
Where is the last >
?
Why <p><img alt="" src="upfiles/54591303758197437.jpg" /></p>
won't show up in the webpage?
![]()
'`, it still breaks for me in Safari. Though adding an extra space at the end fixes it. :confused: – rmn Sep 11 '18 at 12:29