JSFiddle - React, Tailwind, and code Playground
HTML
<select id="countries">
<option val="USA">USA</option>
<option val="Canada">Canada</option>
<option val="Australia">Australia</option>
</select>
<select id="cities">
<option val="Vancouver">Vancouver</option>
<option val="New York">New York</option>
</select>
JavaScript
// initially hide the cities
$('#cities').hide();
$("#countries").change(function() {
// find the selected country
var selectedCountry = $(this).val();
// if US or Canada
if(selectedCountry == "USA" || selectedCountry == "Canada") {
// show the cities list
$("#cities").show();
}
// otherwise hide it
else {
$("#cities").hide();
}
});
// if US or Canada is the already selected option, then
// cities should show up rightaway
$('#countries').trigger('change');