How To Add Options To A Select Element Using Jquery?

The finest example using HTML, and jQuery is what I’ve presented. Therefore, you can learn how to add new select options using jQuery. Simple explanations are provided for each stage.


  1. Create a HTML Code:
<!DOCTYPE html>
    <script src="">
      Select one of the proposed options:
      <select id="mySelect">
        <option value="option1">Option 1</option>
        <option value="option2">Option 2</option>


2. Create JavaScript Code:

<script type="text/javascript">    
      jQuery(document).ready(function () {
        var optionText = 'Option 3';
        var optionValue = 'option3';

This code creates a new option element with a value of “option3” and text of “Option 3”, and then appends it to the select element with the ID of “mySelect”. You can add more options in a similar way by calling the append() method again with a new option element.





Submit a Comment

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


Select Categories