Skip to content

Instantly share code, notes, and snippets.

@mcavaliere
Last active December 22, 2015 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcavaliere/be9cb91f61e114de8c7c to your computer and use it in GitHub Desktop.
Save mcavaliere/be9cb91f61e114de8c7c to your computer and use it in GitHub Desktop.
// Heavily Coupled
$(function() {
$(document.body).append( $('<select id="countries"></select>') );
var countriesIveBeenTo = {
'BE': 'Belgium',
'CR': 'Costa Rica',
'IT': 'Italy',
'US': 'United States of America',
'UK': 'United Kingdom'
};
$.each(countriesIveBeenTo, function(val, text) {
$('select#countries').append(
$('<option value="' + val + '">' + text + '</option>')
);
});
$('select#countries').change(function() {
console.log('Selected country: ' + $('select#countries :selected').text());
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment