White background in select box when viewing in Chrome

后端 未结 4 497
温柔的废话
温柔的废话 2021-01-19 05:37

this html only in chrome makes the selected value non visible, the bacground of the select in other browsers is colored, only in chrome it\'s white



        
4条回答
  •  终归单人心
    2021-01-19 06:09

    First you have to detect the browser to fix the issue:

    var userAgent = navigator.userAgent.toLowerCase();
    $.browser = {
        version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
        chrome: /chrome/.test( userAgent ),
        safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
        opera: /opera/.test( userAgent ),
        msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
        mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
    };
    

    Then change the font color to black:

    $.each($.browser, function(i, val) {
    if($.browser.chrome){
    $(o).css({'color':'black'});
    }
    });
    

提交回复
热议问题