Changing only the color of Chinese characters in page title and menu
-
Hello WP,
New web developer here! I’m trying to change only the color of the Chinese characters in my website’s page titles and menu. I wrote the following JavaScript and added it to themes/harmonic/js/
(function($) { $('h1').each(function() { var text = $(this).html(); $(this).html(text.replace(/([\u4E00-\u9FFF])/g, '<span lang="zh">$1</span>')); }); })(jQuery);
I then added the following php code to functions.php in themes/harmonic/
function red_zh_char_method() { wp_enqueue_script( 'red-zh-char-script', get_stylesheet_directory_uri() . '/js/red-zh-char.js', array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'red_zh_char_method' );
How would I update style.css to add in the following:
span[lang="zh"] { color: red; }
Also, is there any way I could adapt the code for the menu?
I look forward to any insight you may have!
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Changing only the color of Chinese characters in page title and menu’ is closed to new replies.