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:
- It is used to return the name property.
metaObject.name
- It is used to set the name property.
metaObject.name = name
Property Values:
- name: It specifies the name of the Meta Element.
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.
HTML
<!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.
HTML
<!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:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
16 Jun, 2023
Like Article
Save Article