Created
April 4, 2012 13:33
-
-
Save ptrin/2301069 to your computer and use it in GitHub Desktop.
Accessible fancy select js. Modified from http://cssglobe.com/post/8802/custom-styling-of-the-select-elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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