I have the following code, and I would like to manipulate it slightly, but feel more familiar doing so in plain javascript:
jQuery ->
states = $('#person_state_id').html()
console.log(states)
$('#person_country_id').change ->
country = $('#person_country_id :selected').text()
options = $(states).filter("optgroup[label=#{country}]").html()
console.log(options)
if options
$('#person_state_id').html(options)
else
$('#person_state_id').empty()
Thanks!
1 Answer