Answers for "get value from select option"

8

select option value jquery

$("select.country").change(function(){
  var selectedCountry = $(this).children("option:selected").val();
  alert("You have selected the country - " + selectedCountry);
});
Posted by: Guest on February-19-2020
0

get value from select tag

<form>
  Select your favorite fruit:
  <select id="mySelect">
    <option value="apple">Apple</option>
    <option value="orange">Orange</option>
    <option value="pineapple">Pineapple</option>
    <option value="banana">Banana</option>
  </select>
</form>

<script>
function myFunction() {
  var x = document.getElementById("mySelect").value;
  console.log(x);
}
</script>
Posted by: Guest on July-04-2021

Code answers related to "get value from select option"

Code answers related to "Javascript"

Browse Popular Code Answers by Language