Skip to main content
added 228 characters in body
Source Link
$("#id option").remove();
$("#id").append('<option value="testValue" >TestText</option>');

The first line of code will remove all the options of a select box as no option find criteria has been mentioned.

The second line of code will add the Option with the specified value("testValue") and Text("TestText").

$("#id option").remove();
$("#id").append('<option value="testValue" >TestText</option>');
$("#id option").remove();
$("#id").append('<option value="testValue" >TestText</option>');

The first line of code will remove all the options of a select box as no option find criteria has been mentioned.

The second line of code will add the Option with the specified value("testValue") and Text("TestText").

Post Undeleted by Devkinandan Chauhan
Post Deleted by Devkinandan Chauhan
Source Link

$("#id option").remove();
$("#id").append('<option value="testValue" >TestText</option>');