young coder
New Member
I am facing a very strange problem where the jQuery :selected is always returning the same value.For the example, lets say I have this HTML:\[code\]<select class="some_select"> <option value="http://stackoverflow.com/questions/15513418/0">Zero</option> <option value="http://stackoverflow.com/questions/15513418/1">One</option></select>\[/code\]then I run this jQuery code on $(document).ready():\[code\] $('.some_select').change(function() { alert($(this).attr('value')); });\[/code\]In the case above, the alert always display the good value of the selected option, but if I run this:\[code\]var type = $('.some_select :selected').attr('value');\[/code\]with this code, the alert always return '0', no matter what option is selected.I also tried with:\[code\]$('.some_select').find(':selected')\[/code\]and\[code\]$('.some_select').filter(':selected')\[/code\]also\[code\]$('.some_select option:selected')\[/code\]Thanks In advance for any help!