I need to keep each character passed to .html() as is i.e. not encoded. For example, .html('>') to save the less-than character as >, not <. How would I do this? Ideally, the solution would apply to all “special” characters e.g. <, &, etc.
<h1 id="my-title"></h1>
// JavaScript / jQuery code.
$('#my-title').html('>');
...
...
// Somewhere else in the code, I need to retrieve the value back by calling
// var v = $('#my-title').html();
Instead of
.html()use.text()to save and retrieve the value.Note that you need to use
.text()for saving the value as well. There’s a reason why<and>become encoded…