-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjquery.select.js
30 lines (30 loc) · 934 Bytes
/
jquery.select.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(function($){
$.fn.extend({
customStyle : function(options) {
var defaults = {
selClass: 'custom-select',
labelClass: 'custom-select-label'
};
options = $.extend(defaults, options);
if(!$.browser.msie){
return this.each(function() {
var select = $(this),
val = select.find(":selected"),
name = select.prop('id'),
o = options,
label, time;
if(typeof name === 'undefined'){
time = new Date();
name = 'select-id-' + time.getTime();
select.prop('id', name);
}
select.addClass(o.selClass).after('<label class="'+o.labelClass+'" for="' + name + '">'+val.text()+'</label>');
label = select.next();
select.change(function(){
label.text(select.val());
});
});
}
}
});
})(jQuery);