I have a tag containing ▼ ; (which is displayed as ▼ on the rendered page) :
<span id=up_down>▼</span>
The problem is that when I try and compare innerHTML against ▼ ;
it is instead trying to compare ▼ == ▼ ; (and failing)
var e = document.getElementById("up_down");
if ( e.innerHTML == '▲' )
{
e.innerHTML = '▼';
}
else if ( e.innerHTML == '▼' )
{
e.innerHTML = '▲';
}
Try to escape()
it and use %u25BC
and %u25B2
instead.
var e = document.getElementById("up_down");
if ( escape(e.innerHTML) == '%u25B2' )
{
e.innerHTML = '▼';
}
else if ( escape(e.innerHTML) == '%u25BC' )
{
e.innerHTML = '▲';
}
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With