How to get value from select option

With JQuery, we can get easily select option value onchange event in jquery. if you have a question like how to get select option value on change jquery than here you will have a simple example of getting selected value of dropdown in jquery on change event.

In Jquery, we can get value from a selected value using onchange event in jquery. just click on the value you can easily get the value.

In this example, I am using onchange event. you can check from below code.

$(".getvalue").change(function(){

    var selValue = $(this).val();

    alert(selValue);

});

So, let’s see bellow simple example so it will helpful for you.

Example:


<!DOCTYPE html>
<html>
<head>
   <title>Get Selected value from drop using jqery: Real Programmer</title>
   <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<h3>Get Selected value from drop using jqery</h3>
<select name="webste" class="getvalue">
    <option>Select Course</option>
    <option value="java">Java</option>
    <option value="nodejs">Node Js</option>
    <option value="PHP">PHP</option>
</select>
   
<script type="text/javascript">
    $(".getvalue").change(function(){
        var selValue = $(this).val();
        alert(selValue);
    });
</script>
   
</body>
</html>
Leave a Comment