Open In App

HTML DOM Meta name Property

The HTML DOM Meta name Property is used for returning or setting the name of the name and it is used to reference form data when it has been submitted by the user. It also refers to the element in the javascript. 

Syntax: 



metaObject.name
metaObject.name = name

Property Values:

Return Value: It returns a string value that represents the name of the Meta Element. 



Example 1: This program illustrates how to return the name Property. 




<!DOCTYPE html>
<html>
   
<head>
    <meta name="keywords"
          content="Meta Tags, Metadata" />
</head>
   
<body>
    <h1>GeeksForGeeks</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello GeeksforGeeks!</p>
    <button onclick="myGeeks()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            let x = document.getElementsByTagName(
                    "META")[0].name;
            document.getElementById(
                "sudo").innerHTML = x;
        }
    </script>
</body>
   
</html>

Output: 

 

 Example 2: This program illustrates how to set the name Property. 




<!DOCTYPE html>
<html>
   
<head>
    <meta name="keywords"
          content="Meta Tags, Metadata" />
</head>
   
<body>
    <h1>GeeksForGeeks</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello GeeksforGeeks!</p>
    <button onclick="myGeeks()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            let x = document.getElementsByTagName(
                    "META")[0].name = "Hello Geeks";
            document.getElementById(
                "sudo").innerHTML = x;
        }
    </script>
</body>
   
</html>

Output: 

 

Supported Browsers: The browsers supported by DOM Meta name Property are listed below:


Article Tags :