Witam,

Znalazłem taki skrypt dzięki któremu mogę ostylować pole select:

  1. (function(jQuery){
  2. jQuery.fn.extend({
  3.  
  4. customStyle : function(options) {
  5. if(!jQuery.browser.msie || (jQuery.browser.msie&&jQuery.browser.version>6)){
  6. return this.each(function() {
  7.  
  8. var currentSelected = jQuery(this).find(':selected');
  9. jQuery(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:jQuery(this).next().css('font-size')});
  10. var selectBoxSpan = jQuery(this).next();
  11. var selectBoxWidth = parseInt(jQuery(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));
  12. var selectBoxSpanInner = selectBoxSpan.find(':first-child');
  13. selectBoxSpan.css({display:'inline-block'});
  14. selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
  15. var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
  16. jQuery(this).height(selectBoxHeight).change(function(){
  17. // selectBoxSpanInner.text(jQuery(this).val()).parent().addClass('changed'); This was not ideal
  18. selectBoxSpanInner.text(jQuery(this).find(':selected').text()).parent().addClass('changed');
  19. // Thanks to Juarez Filho & PaddyMurphy
  20. });
  21.  
  22. });
  23. }
  24. }
  25. });
  26. })(jQuery);
  27.  
  28. jQuery(function(){
  29.  
  30. jQuery('select#activity-filter-by').customStyle();
  31.  
  32. });



Problem jest taki że gdy zaznaczę jakieś pole np. Topics i przeładuję stronę to pole select pokazuje "Everything" a pod spodem są wyświetlane Topics

Tutaj można zobaczyć demo bez użycia skrypty powyżej - buddyboss.com/demo/activity/

Nie wiem skąd przeglądarka bierze informację że przed przeładowaniem strony zaznaczone było pole Topics

Problem w tym że jquery zwraca błędny:
  1. jQuery(this).find(':selected');