Here is the jsfiddle link: http://jsfiddle.net/a3LwW/4/
I am facing an issue with multiple spaces in the content of <option>
Although jQuery's val()
returns the correct value, the browser renders the <option>
as if there is only a single space in the string.
Is there a way to display multiple spaces correctly in the <option>
element?
I've tried using
<option><pre>three spaces</pre></option>
, but it doesn't give me the desired result.
HTML
<select id="list">
<option>one space</option>
<option>two spaces</option>
<option>three spaces</option>
</select>
<p>Current Value:<pre id="val"></pre></p>
JS
function update_val () {
$('#val').text($('#list').val());
}
$('#list').change(update_val);
//initialize
update_val();