Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Question about option selected="selected" and jquery option:selected.


nelsonm - 9:11 pm on Jun 4, 2012 (gmt 0)


hi all,

I know that the select tag's option selected="selected" just puts the option text in the select's display field on page load.

I also know that...
$('select').val()
$('select :selected').val()
$('select option:selected').val()

and
$('select :selected').text()
$('select option:selected').text()

are all functionally the same in that they all get the current option value and text respectively.

My question is...
Does the jquery selector ":selected" and "option:selected" component attempt to reference the select tag's selected option selected="selected" if any, or does it merely get the value or text of what's currently displayed in the select field and there is no relation between the tag's option="selected" and jquery "option:selected"?


Thread source:: http://www.webmasterworld.com/javascript/4461372.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com