I\'m using this for a show/hide div expander, which is working fine, however, the HTML entities aren\'t being outputted.
$(document).ready(function() {
$(\'.
.text
already does the conversion from "text" to "HTML" itself.
From the documentation:
We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), which replaces special characters with their HTML entity equivalents (such as < for <).
So your text is being converted to ▲
and thus being rendered, from your point-of-view, verbatim.
You can encode the literal directly into the string (noting that the Javascript \u
expects Hex, not Decimal):
$(this).text("\u25B2 See Less");
If you want to use the HTML entities:
$(this).html("▲ See Less");
See this jsfiddle.net snippet that shows:
.html
.