Skip to content

Instantly share code, notes, and snippets.

View mdcpepper's full-sized avatar

Mike Pepper mdcpepper

View GitHub Profile
@mdcpepper
mdcpepper / jquery.ul_to_select.js
Created July 6, 2009 13:47
jQuery function for converting an unordered list of links to a select element 'jumpbox'
jQuery.fn.ul_to_select = function(){
return this.each(function(){
var select_box = document.createElement('select');
select_box.id = this.id + '_select'
this.parentNode.insertBefore(select_box, this);
$('<option></option>').html('Choose...').appendTo('#'+select_box.id);
$(this).find('li a').each(function(link){
$('<option></option>').html(this.innerHTML).attr('value', this.href).appendTo('#'+select_box.id);
});
this.parentNode.removeChild(this);