add meta tag by javascript code example

Example 1: append meta tag to head javascript

<script>  var link = document.createElement('meta');  link.setAttribute('name', 'shareaholic:url');  link.content = document.location;  document.getElementsByTagName('head')[0].appendChild(link);</script>

Example 2: how to use a script to inject a meta attribute in html

document.addEventListener('requireready', function onRequireReady() {
            require(['jquery'], function run($) {
                $(document).ready(function () {
                    $(".className").closest("element").attr("tag", "value");
                });
            });
        });