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

#22694
Ernest MarcinkoErnest Marcinko
Keymaster

You might be right. Maybe try this one, where it will run the coloring section upon page load, even if there was no change:

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;');
           }
         });
  	$('select').each(function(){
    	   if ( $(this).prop('selectedIndex') == 0 ) {
      	    $(this).css('cssText', 'color: ' + color1 + ' !important;');
           } else {
      	    $(this).css('cssText', 'color: ' + color2 + ' !important;');
           }
         });
  });
  </script>
  <?php
}