i have got this HTML code:
<select name="audience[8787330733][value]">
<option value=""></option>
<option value="80">Everyone</option>
<option selected="1" value="50">Friends of Friends</option>
<option value="40">Friends</option>
</select>
now i want to find out which of these options are selected.
i tried
$('select[name="audience[8787330733][value]"] option:selected').text();
but this does not work 🙁
I think I didn’t escaped the name in the right way…
Thank you for your answers!!! 🙂
You should reference elements by id as it’s the fastest selector as in @Arif’s answer.
If it is not possible for you to change the html you can try:
(escaping special symbols in jQuery selectors can be achieved by using double backslashes)
http://jsfiddle.net/TfThK/ – tested on your example.