All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

Get Selected Option Value jQuery

Last Updated : Mar 11, 2024

Get Selected Option Value jQuery

In this article we will show you the solution of get selected option value jQuery, a user can choose from a variety of options using a multiple-choice box. To pick numerous alternatives, keep the control key depressed on a Mac or Windows computer.

By including the attribute multiple in the choose> element, you can allow several sections in a select box.

Use jQuery:selected selection and also the val() method to find the html value of a selected item inside a pick box or dropdown list.

Pull-down lists are made utilizing the "select" element rather than the "input" tag.

In the paired tag, the opening tag "select" comes before the closing tag "/select". The option> tag must be used in order to use this tag.

Step By Step Guide On Get Selected Option Value jQuery :-

<meta name="viewport" content="width=device-width, initial-scale=1">
        h1 {
            color: green;
        h5 {
            color: green;
        h4 {
            color: green;
        p {
        color: red;
        .select {
        margin: 40px;
        width: 60%;
        height: 300px;
        padding: 30px;
        border: 2px solid green;
body {
        background-color: pink;
<script src="">
$(document).ready (function () {
    $("").change (function () {
        var selectedCountry = $(this).children("option:selected").val();
        alert ("You have selected the country - " + selectedCountry);
<div class ="select">
<h1> Example 1 </h1>
<p> <b> Get Selected Value in drop-down using jQuery </b> </p>
<form action="#" method ="post" >
    <label> <h4> Select Country from drop-down list: </h4> <br> </label>
    <select class="country">
         <option value="usa"> United States </option>
         <option value="india"> India </option>
         <option value="uk"> United Kingdom </option>
<option value ="brazil"> Brazil </option>
         <option value ="germany"> Germany </option>
  1. The first step is to write <HTML>, which tells the browser what version of HTML we're using. A tag is the first element of an HTML document.
  2. Use the <head> tag to describe the project's heading. In contrast to the final brackets, which are closed, the title and final brackets both are open. External style sheets, also known as step-by-step style sheets, appear on a webpage based on the URL or path.
  3. Next, we create the font size and weight in style.
  4. Then we style by closing our eyes.
  5. The <script> tag was then added. The script tag also includes the javascript google API run or an explanation of the code or file we used.
  6. The script is then closed.
  7. The <body> tag, which describes the webpage's body, is then placed after this. This is where the website's content is written.
  8. Then with the <select> and <option> tags, we have produced a drop-down list.
  9. Let's say that after choosing an element from the "option" list, we choose a certain value from the "option" list.
  10. In that instance, it will show a alert message the with element you select in the drop-down list.

Conclusion :-

The choice and option tags can be used to create drop-down menus. The user has the choice to choose one, several, or each of the options.

All of the options in a drop-down list are visible when a user selects one, even when they are not visible on the screen. They are used to save space when displaying just one item in the list.

I hope this article on get selected option value jQuery helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Ashish

Ashish is a dynamic and motivated individual with a passion of programming and an experienced programmer having 3+ years of experience in various languages like Java, Python, HTML, CSS, JavaScript, jQuery and various frameworks like Bootstrap

Follow Ashish On Linkedin 🡪