Skip to content

Instantly share code, notes, and snippets.

@ptrin
Created April 4, 2012 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptrin/2301069 to your computer and use it in GitHub Desktop.
Save ptrin/2301069 to your computer and use it in GitHub Desktop.
$('select.select').each(function(){
var title = $(this).attr('title');
if( $('option:selected', this).val() != '' ) title = $('option:selected',this).text();
$(this)
.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
.after('<span class="select">' + title + '</span>')
.on('change',function(e){
val = $('option:selected',this).text();
$(this).next().text(val);
})
.focus( function() {
$(this).next().addClass('s-focused');
$(document).on('keyup',function(e) {
console.log(e);
});
})
.blur ( function() {
$(this).next().removeClass('s-focused');
$(document).off('keyup');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment