Get Meta Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Meta

Introduction

The Meta object represents an HTML <meta> element.

You can access a <meta> element by using getElementsByTagName():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="tutorials">
</head>/*from w  ww .j a  va 2s  .co  m*/
<body>

<button onclick="myFunction()">get the content of the meta information</button>

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

<script>
function myFunction() {
    var x = document.getElementsByTagName("META")[0].content;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials