Skip to content
Related Articles

Related Articles

HTML | DOM Cite Object
  • Last Updated : 16 Jan, 2019

The DOM Cite Object is used to represent HTML <Cite> element. The Cite element is accessed by getElementById().

Syntax

document.getElementById("id");

Where “id” is the ID assigned to the cite tag.

Example-1:




<!DOCTYPE html>
<html>
  
<head>
    <title>DOM cite Object</title>
    <style>
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
              /wp-content/uploads/geeksforgeeks-25.png" 
         alt="gfg">
  
    <!-- cite id-->
    <p><cite id="GFG">GeeksforGeeks Image</cite></p>
  
    <button onclick="Geeks()">Submit</button>
  
    <script>
        function Geeks() {
            var w = document.getElementById("GFG");
            w.style.color = "coral";
            w.style.fontWeight = "bold";
        }
    </script>
</body>
  
</html>             

Output:



Before Clicking on Button:

After Clicking On Button:

Example-2: Cite Object can be created by using the document.createElement method.




<!DOCTYPE html>
<html>
  
<head>
    <title>DOM cite Object</title>
    <style>
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h2>DOM Cite Object</h2>
    
    <button onclick="Geeks()">
      Submit
    </button>
    
              /wp-content/uploads/geeksforgeeks-25.png" 
         alt="gfg">
    
    <script>
        function Geeks() {
            var cite = document.createElement("CITE");
            
            var text = 
            document.createTextNode("GeeksforGeeks Image");
            
            cite.appendChild(text);
            document.body.appendChild(cite);
        }
    </script>
</body>
  
</html>                    

Output
Before Clicking on Button:

Afte Clicking on Button:

Supported Browsers: The browser supported by DOM Cite Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :