Meta content Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Meta


The content property sets or gets the content attribute of a meta element.

The available values are the httpEquiv properties.

Set the content property:

Value Description
text The content of the meta information

Return Value

Type Description
String The value of the content attribute of the meta element

The following code shows how to return the value of the content attribute of the third meta element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML5,CSS,JavaScript">
<meta name="author" content="your name">
</head>/*from   w w  w  . j  av a 2s  .co m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var v = document.getElementsByTagName("META")[2].content;
    document.getElementById("demo").innerHTML = v;


Related Tutorials