I want to create a drop-down menu in which the second choice will be displayed if the data of the first choice belongs to a certain category.
As you can see below, the first choice will be dedicated to COUNTRIES. If the selected country has states, then a second snapshot containing the states of that country will be displayed.
1) Is there a tag (in my code “xyz”) that I can use to separate countries in the categories “state” and “without state”? If so, how can I find out the meaning of the "xyz" tag?
2) If I use:
<option class="no-state" value="Germany">Germany</option>
and then use jQuery to read, it will give me GermanySpain value (this is correct, but not what I want)
$('.no-state').val();
HTML PART
<div id="country">
<select>
<option xyz="no-state" value="Germany">Germany</option>
<option xyz="state" value="USA">USA</option>
<option xyz="no-state" value="Spain">Spain</option>
</select>
</div>
<div id="state" style="display:none" >
<select>
<option value="Utah">Utah</option>
<option value="New York">New York</option>
<option value="California">California</option>
</select>
</div>
PART OF JERKVI
$(document).ready(function(){
$('#country').change(function() {
if (the value of "xyz" tag is === 'no-state')
{
$('div#state').hide();
}
else
{
$('div#state').show();
}
});
});
What can I do to solve this problem?
Thank.