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>


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.


source to share

4 answers

You just need to call

var content = $('#oi_report_contact_sex option:selected').html();


to get the inner content of the selected option.



You can use the method .text()

to get the text value. Like this .

$('#oi_report_contact_sex').on('change', function () {
  alert($('#oi_report_contact_sex option:selected').text());








You may try:

$("#oi_report_contact_sex option[value='" + $("#oi_report_contact_sex").val() + "']").text()


jsFiddle link:



All Articles