JSFiddle - React, Tailwind, and code Playground
HTML
<select id="testing">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<button id="remove">Remove</button>
<button id="restore">Restore</button>
<div id="debug"></div>
JavaScript
//jquery returns an object
var sel = $('#testing'),
opts =[],
debug = $('#debug');
debug.append(typeof sel);
var opt_array = sel.attr('options');
//for(var i = 0, len = opt_array.length; i < len; ++i)
for (var a in opt_array)
{
debug.append(a + ':' + opt_array[a] + "<br>");
//opts.push(opt_array[a]);
}
//delete the first option
function remove()
{
$('#testing option:first').remove();
}
function restore()
{
sel.options.length = 0;
for(var i = 0, len = opts.length; i < len; ++i)
{
//debug.append(a + ':' + opts[a] + '<br>');
sel.options.add(opts[i]);
}
}
*/
$('#remove').click(remove);
$('#restore').click(restore);