简体   繁体   English

根据meta标签的内容将类添加到正文

[英]Add class to body depending on the content of meta tag

Sorry for my English but I think its pretty easy to understand. 对不起,我的英语很不错,但我认为它很容易理解。

I use different languages on a website. 我在网站上使用其他语言。 I want to add a class to the body when the German language is selected. 选择德语后,我想向身体添加一个类。

<meta http-equiv="language" content="DE">

Tried this, but seems like its making no effect: 尝试过此方法,但似乎没有效果:

   $(function() {
            if  ($("meta[http-equiv='language']").attr("content") === "DE")) {
                $("body").addClass("german");
            }
    });
if(jQuery('meta[http-equiv="language"]').attr('content') === 'DE'){
    jQuery('body').addClass(yourclass);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM