access selected option in jquery
<select id="myselect">
<option value="1">Mr</option>
<option value="2" selected="selected">Mrs</option>
<option value="3">Ms</option>
<option value="4">Dr</option>
<option value="5">Prof</option>
</select>
<script>
alert($( "#myselect" ).val()); //alert '2'
//OR
alert($( "#myselect option:selected" ).attr('value')); //alert '2'
//Use this if you want to get the label and not the value
alert($( "#myselect option:selected" ).text()); //alert 'Mrs'
</script>$("#vacc_wellness_agegroups option:selected").val();$( "#myselect option:selected" ).text();
// => "Mr"
Also in JavaScript:
- variables in js
- jquery autocomplete database
- jquery select specific radio button by value
- how to remove warnings in react js console
- get div text jquery
- javascript determine if string is valid url
- Exception in thread "main" org.openqa.selenium.JavascriptException:
- js for
- UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
- how to freeze js object
- javascript date get day of week abbreviation
- javascript appendchild at index
- pagination.js
- jquery ajax upload image
- enzyme configure adapter
- javascript innertext vs innerhtml
- jquery loop through each child element
- page reload timeout
- javascript array reorder elements
- how to validate the textbox using jquery
- angular stable version
- pushing element in array in javascript
- express get host url
- jquery alertify