javascript - Why does using replace to unescape html tags strips out all other html tags as well? -
i need convert < , > in table < , >. function i'm using works well.
<div class="schedule"> <table> <tbody> <tr> <td>lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.<br /> <em>ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</em><br />duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</td> </tr> </tbody> </table> </div> and
$('.table-container td').each(function(){ var $this = $(this); var t = $this.text(); $this.html(t.replace('<','<').replace('>', '>')); }); however, function removes <em> tags don't need unescaping. know why?
because used .text() html content.
use .html() instead:
var t = $this.html();
Comments
Post a Comment