<!DOCTYPE html>
<
html
>
<
head
>
</
script
>
<
meta
charset
=
"utf-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
>
<
title
>Add an option to the dropdown list using jquery.</
title
>
</
head
>
<
body
>
<
h1
style
=
"color: green;"
>GeeksForGeeks</
h1
>
<
p
>Programming Languages :</
p
>
<
select
id
=
'programmingLanguage'
>
<
option
value
=
"Java"
style="color: green;
font-weight: 700;">Java</
option
>
<
option
value
=
"Python"
style="color: green;
font-weight: 700;">Python</
option
>
<
option
value
=
"CPP"
style="color: green;
font-weight: 700;">CPP</
option
>
<
option
value
=
"C"
style="color: green;
font-weight: 700;">C</
option
>
</
select
>
<
p
> Click to add C# and PHP programming languages</
p
>
<
button
onclick
=
"addOption()"
>Add option</
button
>
<
script
>
function addOption() {
var options = {
val1: 'C#',
val2: 'PHP'
};
var selectOption = $('#programmingLanguage');
$.each(options, function (val, text) {
selectOption.append(
$('<
option
></
option
>').val(val).html(text)
);
});
}
</
script
>
</
body
>
</
html
>