JSFiddle - React, Tailwind, and code Playground

by axl163

HTML

<div id='myForm'>
My form.
</div>
<button onclick="addAllInputs('myForm', 'select');">
add select input
</button>

JavaScript

var arr = [
  {val : 1, text: 'One'},
  {val : 2, text: 'Two'},
  {val : 3, text: 'Three'}
];

var sel = $('<select>').appendTo('body');
$(arr).each(function() {
 sel.append($("<option>").attr('value',this.val).text(this.text));
});