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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
Before Click on the Button :

After Click on the Button :

Example 2: Quote Object can be created by using the document.createElement Method.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.