Q:

Change options of select using jQuery

0

Change options of select using jQuery.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now