Skip to content

Instantly share code, notes, and snippets.

@markupboy
Created August 2, 2010 21:31
Show Gist options
  • Save markupboy/505354 to your computer and use it in GitHub Desktop.
Save markupboy/505354 to your computer and use it in GitHub Desktop.
$.fn.selectReplace = function() {
if (!($.browser.msie && $.browser.version < 7)) {
return this.each(function() {
var $this = $(this);
$this.wrap('<span id="' + $this.attr('id') + '_wrapper" class="select_wrapper"></span>')
.before('<span>' + $this.find('option[value=' + $this.val() + ']').html() + '</span>')
.css("opacity", 0)
.change(function() {
$this.parent().find('span').html($this.find('option[value=' + $this.val() + ']').html());
});
});
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment