Skip to content
Related Articles

Related Articles

Improve Article
HTML | DOM Quote Object
  • Last Updated : 23 Jan, 2019

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:






<!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.




<!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", 
                        "http://www.geeksforgeeks.org, 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



My Personal Notes arrow_drop_up
Recommended Articles
Page :