VOOZH about

URL: https://www.geeksforgeeks.org/jquery/how-to-change-options-of-select-with-jquery/

⇱ How to Change Options of <select> with jQuery ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Change Options of <select> with jQuery ?

Last Updated : 23 Jul, 2025

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.

Prerequisites

Syntax

$("#op4").empty().append(text)

Approach

  • Create 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.

Output:

👁 gif2final1
change options of with jQuery
Comment
Article Tags:

Explore