Skip to content

Instantly share code, notes, and snippets.

@impronunciable
Created November 29, 2011 13:36
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 impronunciable/1404821 to your computer and use it in GitHub Desktop.
Save impronunciable/1404821 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
$('#s,label[for=s]').hide();
var sel_list = $('<div id="sel_list"><strong><span></span></strong><ul></ul></div>');
sel_list.find('span').text($('label[for=s]').text());
$('#s').children('option').each(function(){
sel_list.children('ul').append('<li>' + $(this).text() + '</li>');
});
$('#s').after(sel_list);
$('#sel_list').find('li').live('click',function(e){
$('#s option').eq($(this).index()).attr('selected','selected').siblings('option').removeAttr('selected');
$(this).parent().hide();
});
$('#sel_list strong').live('click',function(e){
e.preventDefault();
$('#sel_list ul').toggle();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment