Skip to content
Advertisement

How to change multiple meta tag descriptions with a single variable (vanilla JS)?

I have the following meta tags on my website:

JavaScript

All 3 of these meta properties are necessary on my site. However, is there a way to reference a single description in a JS variable that I can pass to each of these content attributes?

Advertisement

Answer

You can use the querySelector with meta[key=value] and then set Attribute with setAttribute(key,value).

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement