How to get selected option value from select inside div


zabi

I have the following html code

<div id="BrokersList4ServiceEndWrapper">
  <select id="BrokersList4ServiceEnd">
   <option value="1">s1</option>
   <option value="2">s2</option>
  </select>
</div>

I tried

  1. Set the selected value to 1.
  2. Get the value of the second option.
  3. get selected value

in jQuery, but not done correctly, if there is any way to easily know the selection syntax, please note

Rajabrabhu Aravindasamy

Set the selected value to 1.

$('#BrokersList4ServiceEnd').val(1);

Get the value of the second option.

$('#BrokersList4ServiceEnd option:eq(1)').val()

get selected value

$('#BrokersList4ServiceEnd').val()

demo

Related


How to get selected option value from select inside div

zabi I have the following html code <div id="BrokersList4ServiceEndWrapper"> <select id="BrokersList4ServiceEnd"> <option value="1">s1</option> <option value="2">s2</option> </select> </div> I tried Set the selected value to 1. Get the value of the

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get selected option value in Select dropdown

username How to get selected option value in jQuery's select dropdown <select> <option value="100">one</option> <option value="263">two</option> <option value="500">three</option> <option value="768">four</option> </select> The opt

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get the value of the selected option in a select box

giff if I want to show an alert with a checked option, but my form doesn't see the popup alert. Here is my PHP: <select class="form-control" id="status_users"> <option>All</option> <option>Active</option> <option>Inactive</option> <option>Try</option>

How to get selected option value in Select dropdown

username How to get selected option value in jQuery's select dropdown <select> <option value="100">one</option> <option value="263">two</option> <option value="500">three</option> <option value="768">four</option> </select> The opt

Get value of selected option from multiple select fields at once

username Imagine xhow many select fields (values xundetermined) there are. I want to use jQuery (or vanilla JavaScript) to get the value of the selected option for each select field. my method: var cars = $(".select").find("option:selected").val(); $(".select"

Get value of selected option from multiple select fields at once

username Imagine xhow many select fields (values xundetermined) there are. I want to use jQuery (or vanilla JavaScript) to get the value of the selected option for each select field. my method: var cars = $(".select").find("option:selected").val(); $(".select"