I'd like to add an <option> element to a <select> element where the <option> element's text contains an HTML entity: —
In HTML, the code would look like this:
<select name="test" id="test">
<option value="">— Select One —</option>
</select>
My Javascript code looks like this:
function selectOne() {
var e = document.getElementById('test');
e.options[0] = new Option('— Select One —', '');
}
However, as you will see if you test this, the — becomes escaped. I had the same outcome when I tried:
e.options[o].text = '— Select One —';
(observed behavior was in IE7 ... did not test with FireFox/Safari/etc -- Ie7 is the only browser I need at the moment).