HTML | DOM Quote Object
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 >w3wiki</ h1 > < h2 >DOM Quote Object</ h2 > < q id = "GFG" cite = "w3wiki.net" > w3wiki </ q > < br >< br > < button onclick = "Beginner()" > Submit </ button > < p id = "sudo" ></ p > < script > function Beginner() { 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 >w3wiki</ h1 > < h2 >DOM Quote Object</ h2 > < button onclick = "Beginner()" > Submit </ button > < script > function Beginner() { var quote = document.createElement("Q"); var txt = document.createTextNode("w3wiki"); quote.setAttribute("cite", "http://www.w3wiki.net, in"); 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