JSFiddle - React, Tailwind, and code Playground

by Travis Harris

HTML

<div id='first'>
        <h1>project options</h1>
        <button id='button1'>Get Projects</button>
</div>
<div id='second'>
        <h2>all projects</h2>
        Projects: <select id='selector'></select>
</div>

JavaScript

$(document).ready(function () {
  $('#button1').click(function() {
    var selector = document.getElementById('selector');
    var api = '/echo/jsonp/';
    $.getJSON(api, {"1":"example","2":"other example"},function (data) {
      $.each(data, function (index, d) {
        selector.options[selector.options.length] = new Option(d,d);
      });
    });
  });
});