Skip to content

Instantly share code, notes, and snippets.

@KrofDrakula
Created June 15, 2011 10:43
Show Gist options
  • Save KrofDrakula/1026866 to your computer and use it in GitHub Desktop.
Save KrofDrakula/1026866 to your computer and use it in GitHub Desktop.
Select box replacement
(function($) {
$(function() {
var selectBoxes = $('select');
selectBoxes.each(function() {
var $select = $(this).hide(),
$proxy = $('<ul class="selectbox"/>').insertAfter($select);
$select.find('option').each(function() {
// we iterate through the options and create a list item with data-value as value
$proxy.append('<li data-value="' + this.value + '">' + $(this).text() + '</li>');
});
$proxy.delegate('option', 'click', function(ev) {
// update the original select box when an option is selected
$select.val($(this).attr('data-value'));
});
// attach more delegates and/or hide members based on other fields
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment