Skip to content

Instantly share code, notes, and snippets.

@bratsun
Created October 19, 2013 01:29
Show Gist options
  • Save bratsun/7050669 to your computer and use it in GitHub Desktop.
Save bratsun/7050669 to your computer and use it in GitHub Desktop.
Alter selects to grey out on default value and to light up on change
function webformSelect() {
$('.webform-component-select').each(function() {
var t = $(this);
var text = t.find('label').text().replace(' *','');
t.find('option:first').addClass('first').text('Select ' + text);
t.find('select').live('change', function () {
if($(this).find('option:selected').hasClass('first')) $(this).addClass('idle');
else $(this).removeClass('idle');
});
t.find('select').change();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment