How do I compare innerHTML containing a hex character reference?
I have a tag containing & # x25bc; (which is displayed as ▼ on the rendered page):
<span id=up_down>▼</span>
The problem is that when I try and compare innerHTML against & # x25bc;
it is instead trying to compare ▼ == & # x25bc; (and failing)
var e = document.getElementById("up_down");
if ( e.innerHTML == '▲' )
{
e.innerHTML = '▼';
}
else if ( e.innerHTML == '▼' )
{
e.innerHTML = '▲';
}
+3
source to share
3 answers