How to Change Options of <select> with jQuery ? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how we can change options of <select> with the help of jQuery. Here we have options in the select tag and we want to change it dynamically when the user clicks a button. PrerequisitesHTMLCSSJavaScriptjQuerySyntax$("#op4").empty().append(text)ApproachCreate a card structure using Html tags like <div>, <h1>, <h3> for headings and <select>, <option> to create options with values.Add different styling properties to the card like margin, padding, colors, etc using classes, id's, etc to the specific element.Add CDN link in Html file to run jQuery code. Then in script tag write jQuery code.Make a function "clicked" and write the code for setting attributes name and their respective value also write the new value which you want to change from existing value.Select the particular id and empty that one using empty() then append the new option value using append() Invoke the function "clicked" inside click method.New value will appear after clicked on button.Example: This example describe how to change options of <select> with jQuery with HTML, CSS, and jQuery. HTML <!-- HTML code --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Change option using JQuery</title> <link rel="stylesheet" href="style.css"> <script src= "https://code.jquery.com/jquery-3.7.1.min.js" integrity= "sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"> </script> </head> <body> <div class="p-container"> <div class="container"> <h1 class="gfg">GeeksforGeeks</h1> <h3> Change option of select tag using JQuery </h3> <select class="selectstyle"> <option id="op1" value="html">HTML </option> <option id="op2" value="css">CSS </option> <option id="op3" value="js">JS </option> <option id="op4" value="angular">Angular </option> </select> <button id="btn"> Click here to change options </button> </div> </div> <!-- JavaScript Code --> <script> // Jquery Code for change options of // <select> using Jquery $("#btn").click(clicked) function clicked() { // Code to Change option angular to React let text = $('<select></select>') .attr({ "id": "op4", "value": "react" }) .text("React"); $("#op4").empty().append(text) // Code to Change option Js to JavaScript let text2 = $('<select></select>') .attr({ "id": "op3", "value": "javaScript" }) .text("JavaScript"); $("#op3").empty().append(text2) } </script> </body> </html> CSS @import url( 'https://fonts.googleapis.com/css2?family=Poppins&display=swap'); body { font-family: 'Poppins', sans-serif; } .p-container { display: flex; justify-content: center; height: 100vh; align-items: center; } .container { padding: 20px; display: flex; flex-direction: column; gap: 10px; justify-content: center; align-items: center; height: 300px; width: 400px; border: 2px solid black; border-radius: 10px; background-color: #FFFADD; } .gfg { color: green; } #btn { border-radius: 5px; padding: 10px; background-color: #22668D; color: white; } #btn:hover { background-color: #8ECDDD; color: black; } .selectstyle { background-color: #8ECDDD; height: 25px; width: 74px; margin: 20px; border-radius: 5px; } Output: change options of with jQuery Comment More infoAdvertise with us Next Article How to get text value of a selected option in jQuery ? S shivanigupta18rk Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads How to get text value of a selected option in jQuery ? Introduction: In this article, we will see how we can use jQuery to get the text value from the selected option. While working on some form-related user interface, we often use the select option, and to use that, we will surely need those values that are being selected. Approach: We will use select 2 min read How to create Selected Option Select using jQuery Mobile ? jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be creating a Selected Option Select using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel= 1 min read How to add options to a select element using jQuery? We will dynamically add the options to the select element using jQuery. jQuery has a lot of in-built methods. But, we will use some of them to accomplish the purpose of dynamically adding the options to the select element as listed below:Table of ContentBy passing the HTML of the option tag to the a 4 min read How to get text of specific option tag using jQuery? In order to select the text of a selected option or any specific option, jQuery allows doing that easily by its specific selectors. The selector is used to select the specific element. Example: This example selects the text of the specific option(GFG_2) tag. html <!DOCTYPE html> <html> 2 min read How to create Optgroup selects using jQuery Mobile ? jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be creating Optgroup selects using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesh 1 min read How to create a Disabled Option Select using jQuery Mobile ? jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be creating a Disabled Option Select using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel= 1 min read Like