JSFiddle - React, Tailwind, and code Playground
by David Thomas
HTML
<select name="attribute_taxonomy" id="attribute_taxonomy" class="attribute_taxonomy">
<option value="">Custom product attribute</option>
<option value="pa_bedroom">Bedroom</option>
<option value="pa_bathroom">Bathroom</option>
</select>
<button type="button" class="button button-primary add_attribute" disabled>Add</button>
JavaScript
$('#attribute_taxonomy').on('change', function(){
var $this = $(this);
if (!$this.find('option:disabled').length) {
$this
.find('option[value=""]')
.prop('disabled', true)
.end()
.next()
.prop('disabled',false);
}
});
$('.add_attribute').on('click', function () {
var selected = $('#attribute_taxonomy');
alert(selected.val());
});