The Quote Object in HTML DOM is used to represent the HTML <q> element. The quote element can be accessed by using getElementById() method.
Property Value: It contains single attribute value cite. This attribute is used to set or return the value of the cite attribute in a <q> element.
Syntax:
document.getElementById("ID");
Where ID is assigned to the quote tag.
Example 1:
html
<!DOCTYPE html>
<html>
<head>
<title>
HTML DOM Quote Object
</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>DOM Quote Object</h2>
<q id = "GFG" cite = "geeksforgeeks.org">
GeeksforGeeks
</q> <br><br>
<button onclick = "Geeks()">
Submit
</button>
<p id = "sudo"></p>
<script>
function Geeks() {
var ct = document.getElementById("GFG").cite;
document.getElementById("sudo").innerHTML = ct;
}
</script>
</body>
</html>
|
Output:
Before Click on the Button :

After Click on the Button :

Example 2: Quote Object can be created by using the document.createElement Method.
html
<!DOCTYPE html>
<html>
<head>
<title>
HTML DOM Quote Object
</title>
</head>
<body>
<h1>GeeksForGeeks</h1>
<h2>DOM Quote Object</h2>
<button onclick = "Geeks()">
Submit
</button>
<script>
function Geeks() {
var quote = document.createElement("Q");
var txt = document.createTextNode("GeeksForGeeks");
quote.setAttribute("cite",
quote.appendChild(txt);
document.body.appendChild(quote);
}
</script>
</body>
</html>
|
Output:
Before Click on the Button:

After Click on the Button:

Supported Browsers: The browser supported by DOM Quote Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
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 :
24 Nov, 2021
Like Article
Save Article