I want to create a select box dropdown. initially select box will not have any option, it should show only select. On click of select box it will iterate list and add each option to that select box.
I am trying below code -
$(".droptest").click(function(e){
e.preventDefault();
var listDrop = [{"chdk74":"hdk73","hiphdk":"hiphdk","hpghdk":"hpghdk","ihdk":"ihdk","sdg74":"sdg74"}];
var dropDownlist = JSON.parse(listDrop);
var options = "";
$.each(dropDownlist, function(key,value) {
options += "<option name=" + value +" id=" + value +" value="+value+"> "+ value +" </option>";
});
$(".DomainDrop").html(options);
});
<div class="droptest">
<select class="DomainDrop tet" id="DomainDropCreate" name="DomainDrop" required>
<option name="" value="">Select Domain</option>
</select>
</div>