Created
February 6, 2012 18:52
-
-
Save ignacioricci/1754050 to your computer and use it in GitHub Desktop.
Change select to dropdown list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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