This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Color text in custom user meta search fields

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Color text in custom user meta search fields Reply To: Color text in custom user meta search fields

#22652
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Maybe this variation would work better:

add_action('wp_footer', 'asp_custom_option_color');
function asp_custom_option_color() {
  ?>
  <script>
  jQuery(function($){
  	var color1 = '#aaa';
        var color2 = '#000';
    
  	$('select').on('change', function(){
    	if ( $(this).prop('selectedIndex') == 0 ) {
      	    $(this).css('cssText', 'color: ' + color1 + ' !important;');
         } else {
      	    $(this).css('cssText', 'color: ' + color2 + ' !important;');
         }
    });
  });
  </script>
  <?php
}

and the css:

select {color: #aaa !important;}
option:not(first-child) {color:#000 !important;}

This may not work perfectly either, but I think it’s as close as it can possibly get.