P粉7187309562023-08-19 09:58:30
Go to Appearance -> Menu
and click Screen Options
in the upper right corner. Then (if unchecked), check the CSS Classes
option and add a new field for each menu item CSS Classes (optional)
and EN
and DE
add class menu-language
.
Only for DE
Add class lang-DE
Only for EN
Add class lang-EN
Now attached to click event
// 点击时将添加会话存储语言参数 jQuery(document).on("click", ".menu-language", function(){ var lang = jQuery(this).text(); sessionStorage.setItem("language", lang); }); // 每次页面加载时,我们检查语言参数,然后加粗选定的语言 // 默认值为 "DE" var language = sessionStorage.getItem("language") ?? 'DE'; if(language != null) { jQuery(".lang-" + language).css({"font-weight": "bold"}) }
The selected language will now be bolded on every page.