I have HTML output similar to this:
<select> <option value='1'>Item1 </option> </select>
How do I use JavaScript to get the value ‘Item1 ‘ (with the space) rather than ‘Item1’?
In Internet Explorer all the properties I’ve tried, e.g. text, innerHTML, data, nodeValue return ‘Item1’ instead of ‘Item1 ‘.
Interestingly in Firefox, textContent and innerHTML return the untruncated value whereas text returns the truncated value.
Sorry, IE’s parser indeed throws away trailing spaces in <option>. Curiously, if you assign a string with trailing spaces to innerHTML IE manages to remember one of them. Probably best not relied on.
Normally if you want visible trailing spaces (in any browser) you have to use a non-breaking-space character (eg.   character reference).