This post will discuss how to dynamically create a dropdown list in JavaScript and jQuery.

To add a dropdown list dynamically, you would need to create the HTML <select> element, its label and optionally a <br> tag.

In pure JavaScript, you can use the document.createElement() method to programmatically create a dropdown list. Then you can call the Node’s appendChild() method or jQuery’s .append() method to append the dropdown list at the end of a container.

1. Using JavaScript solution

JS


HTML



Edit in JSFiddle

2. Using jQuery solution

JS


HTML



Edit in JSFiddle

 
Alternatively, you can do like:

JS


HTML



Edit in JSFiddle

That’s all about dynamically creating a drop-down list in JavaScript and jQuery.