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

#22633
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Thanks, that may actually help, however you will need both a custom script and a custom CSS code.

1. Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

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('color', color1);
         } else {
      	    $(this).css('color', color2);
         }
    });
  });
  </script>
  <?php
}

2. Also, use this custom CSS:

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

This should basically colorize the first option to grey, and the other ones black, and also handles the changes.