JSFiddle - React, Tailwind, and code Playground
HTML
<fieldset id="billing">
<select id="country-a">
<option>Select a country</option>
<option value="United States">United States</option>
<option value="Ukraine">Ukraine</option>
</select>
<select id="state-a">
<option>Select a state</option>
<option>state one</option>
<option>state two</option>
</select>
<input id="state-field-a" />
</fieldset>
<fieldset id="shipping">
<select id="country-b">
<option>Select a country</option>
<option value="United States">United States</option>
<option value="Ukraine">Ukraine</option>
</select>
<select id="state-b">
<option>Select a state</option>
<option>state one</option>
<option>state two</option>
</select>
<input id="state-field-b" />
</fieldset>
JavaScript
var countrySelects = '#country-a, #country-b',
stateSelects = '#state-a, #state-b',
stateInputs = '#state-field-a, #state-field-b';
$(stateInputs).hide();
$('fieldset').each(function () {
var $fieldset = $(this);
$(countrySelects, $fieldset).change(function () {
var $countrySelect = $(this),
$stateSelect = $(stateSelects, $fieldset),
$stateInput = $(stateInputs, $fieldset);
if ($countrySelect.val() === "United States" || $countrySelect.val() === "Canada" || $countrySelect.val() === "null") {
$stateSelect.show();
$stateInput.hide();
} else {
$stateSelect.hide();
$stateInput.show();
}
})
});