Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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