jQuery

Get Select Box Value With jQuery

Use the following jQuery snippet to get the value of the selected option in the select box.

First create a new jQuery function

function getSelectedOption(id){
     $('#' + id).val();
}

Then create your select box.

<select id="selectBox">
    <option>Select</option>
    <option>Red</option>
    <option>Blue</option>
    <option>Green</option>
    <option>Yellow</option>
    <option>Purple</option>
</select>

Now all you have to do to get the selected value for the select box is call the function you just created.

var text = getSelectedOption('selectBox');
Back to top ^

Join Paulund

  • Get access to 100s of premium tutorials and downloadable content
  • Members content consists of Premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • Priority email development support
  • No ads

Here at Paulund you'll find Web Development tutorials and snippets focusing mainly on PHP, WordPress and CSS. Members will get access to premium tutorials that go into more detail about development with these languages. You will also get access to downloadable premium content based on the tutorial.

Join Paulund

Leave a Reply

Your email address will not be published. Required fields are marked *