I need to change the value of the “content” prop in meta tag… it looks like this is not easy… I looked it up… found a no. of SO threads about this… some respondents seemed horrified – ‘why on earth do you need to change the value of the ‘content’ prop in meta tag???’ well, I need to change it b/c in my website the language changes dynamically, from English to Spanish and vice-versa…
when I switch languages I can see clearly in Firebug how the content of the <title> element changes and also the value for the property “lang” in <html> tag (& other elements…) but the ‘content’ prop in <meta...> elem doesn’t budge (which I set up for it to change, just like for the other elements…)
$("meta#keywords").attr('content',metaKeywords);
etc…
(var metaKeywords of course evaluates to something diff, depending on what language is loaded…)
I even gave the meta tag an id, in the hopes of making it work this way, but it also doesn’t work…
is there any way at all to accomplish this? you can change practically every tag, properties, of tags, etc… dynamically, why not the value for the ‘content’ prop in meta tag? I find this weird…
Since they are there for the benefit of the browser (and spiders) not the user and are not actual page content, I don’t see this working or having the effect you imagine.
Probably something that would be best handled at the back-end.
problem is, I don’t have access to the lang var on the back-end… a while ago I tried to send the value of the ‘lang’ var to the back-end with AJAX, it didn’t work…
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<meta id="metakeywords" name="description" content="A general guide on the use of meta tags in html pages">
</head>
<body>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>
var metakeywords = "hello hello hello";
$("#metakeywords").attr('content',metakeywords);
</script>
</body>
</html>