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
May 14, 2019 at 2:24 pm
#22633
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.