I'm dynamically generating metatags. I'm able to append the properties of the object that are part of the metatag prototype by default. name
, content
and ID
. But when I try to append something different to the object, say foo
it doesn't append.
How do I add my own property so I can add to it in the same way I'm adding the name
id
and content
in the example.
var headID = document.getElementsByTagName("head")[0];
var metaNode = document.createElement('meta');
metaNode.name = "name"; //appends
metaNode.id = "id"; //appends
metaNode.content = "content"; //appends
metaNode.foo = "bar"; //doesn't append
headID.appendChild(metaNode);
result: <meta id="id" name="name" content="content">
want: <meta id="id" name="name" content="content" foo="bar">
metaNode.setAttribute('foo', 'bar');