Get selected parameter data using Jquery or javascript
I need to get the data of a selected parameter whose parameter value is known. I have a parameter value selected and I want the data to be wrapped between the option.
For example, in the following list:
<select name="oi_report_contact[sex]" id="oi_report_contact_sex">
<option value="1">Male</option>
<option value="2">Female</option>
<option value="3">Other</option>
</select>
I have a value of 1, I need to get the Male data via JQuery or Javascript.
Note: $('#oi_report_contact_sex').val();
Will give 1, not masculine when 1 is selected.
+3
source to share
4 answers
You may try:
$("#oi_report_contact_sex option[value='" + $("#oi_report_contact_sex").val() + "']").text()
jsFiddle link: http://jsfiddle.net/ARBb2/1/
0
source to share