简体   繁体   中英

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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