Created
February 19, 2014 14:20
-
-
Save luanmuniz/9093056 to your computer and use it in GitHub Desktop.
Custom select
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
(function($){ | |
'use strict'; | |
$.fn.extend({ | |
customStyle: function(){ | |
var html = $('html'); | |
if (!html.hasClass('ie') || (html.hasClass('ie') && !html.hasClass('lt-ie7'))) { | |
return this.each(function () { | |
var t = $(this), | |
currentSelectedText = t.find(':selected').text(), | |
classes = t.attr('class'); | |
if(!t.parent().hasClass('selectcustom')){ | |
t.wrap('<span class="selectcustom ' + classes + '" />'); | |
t.before('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">' + currentSelectedText + '</span><span class="customStyleIcon"></span></span>'); | |
t.css({'opacity': '0'}).change(function(){ | |
var ts = $(this); | |
ts.parent().addClass('changed').find('.customStyleSelectBoxInner').text(ts.find(':selected').text()); | |
}); | |
} | |
}); | |
} | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment