Skip to content

Instantly share code, notes, and snippets.

@ignacioricci
Created February 6, 2012 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ignacioricci/1754050 to your computer and use it in GitHub Desktop.
Save ignacioricci/1754050 to your computer and use it in GitHub Desktop.
Change select to dropdown list
$('#selectJob').children().hide();
var sel_list = $('<div id="jobDropdown"><strong class="cta"><span></span></strong><ul></ul></div>');
sel_list.find('span').text($('#selectJob label').text());
$('#selectJob select').children('option').each(function(){
sel_list.children('ul').append('<li>' + $(this).text() + '</li>');
});
$('#selectJob').append(sel_list);
$('#jobDropdown').find('li').live('click',function(e){
$('#selectJob select option').eq($(this).index()).attr('selected','selected').siblings('option').removeAttr('selected');
$(this).addClass('selected');
$(this).siblings().removeClass();
$('#jobDropdown strong span').text($(this).text());
$(this).parent().slideUp('slow');
$('input[name="job-position"]').val($(this).text());
});
$('#jobDropdown strong').live('click',function(e){
e.preventDefault();
$('#jobDropdown ul').slideToggle('slow');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment