Skip to content

Instantly share code, notes, and snippets.

View impronunciable's full-sized avatar

Dan Zajdband impronunciable

View GitHub Profile
@impronunciable
impronunciable / select-to-dropdown.js
Created February 6, 2012 19:02 — forked from ignacioricci/select-to-dropdown.js
Change select to dropdown list
var select_to_dropdown = function(el, dropdown, select_text ){
$(el).children().hide();
var sel_list = $('<div id="'+dropdown+'"><strong class="cta"><span></span></strong><ul></ul></div>');
sel_list.find('span').text($(el + ' label').text());
$(el + ' select').children('option').each(function(){
sel_list.children('ul').append('<li>' + $(this).text() + '</li>');
});
$(el).append(sel_list);
$(dropdown).find('li').live('click',function(e){
$(el + ' select option').eq($(this).index()).attr('selected','selected').siblings('option').removeAttr('selected');