Change options of select using jQuery.
HTML Code :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Change options of <select> using jQuery.</title> </head> <body> <select> <option id="c1" value="red">Red</option> <option id="c2" value="green">Green</option> <option id="c3" value="white">White</option> <option id="c4" value="blue">Blue</option> </select> </body> </html>
JavaScript Code:
var option = $('<select></select>').attr("red", "orange").text("Orange"); $("#c3").empty().append(option);
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code :
JavaScript Code: