Skip to content

Instantly share code, notes, and snippets.

@robballou
Created February 12, 2010 17:41
Show Gist options
  • Save robballou/302788 to your computer and use it in GitHub Desktop.
Save robballou/302788 to your computer and use it in GitHub Desktop.
// jQuery plugin
// make "blank" options non-selectable
(function($){
$(document).ready(function(){
jQuery('select').change(function(){
var select = jQuery(this)
var blankValues = ['', '-', '#', ' ']
if(jQuery.inArray(select.val(), blankValues) != -1){
jQuery('option:selected', select).attr('selected', '')
jQuery('option:first', select).attr('selected', 'selected')
}
})
})
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment