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 16, 2019 at 8:02 am
#22694
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
}