0

I m using jQuery to get selected option text value. problem is that it retruns only initial text till space come.

My requirment as follow.

    <select id='list'>
    <option value='1'>This Is Option A</option>
    <option value='2'>This Is Option B</option>
    <option value='3'>This Is Option c</option>
</select>

<script>
alert($('#list').find('option:selected').text());
</script>

*IT Returns only 'This' instead of 'This Is Option A'*

Please Help
kandarp
  • 991
  • 1
  • 14
  • 35

3 Answers3

0

As swetha chinchore said, it is working fine, try to use the latest jquery library..

Script

$("#list").change(function(){
    alert($(this).find("option:selected").text());
});

Fiddle Demo

Aru
  • 1,840
  • 1
  • 12
  • 15
0

Try this:

alert(document.getElementById('list').options[document.getElementById('list').selectedIndex].outerHTML);
Brijesh Bhatt
  • 3,810
  • 3
  • 18
  • 34
0
Its working as expected, check this demo,

http://jsfiddle.net/stanze/02e11v2p/

stanze
  • 2,456
  • 10
  • 13