HTML | DOM Del Object

The Del Object in HTML DOM is used to represent the HTML <del> element. The <del> element can be accessed by getElementById().

Object Properties:

  • cite: It is used to set or return the value of the cite attribute of a deleted element.
  • dateTime: It is used to sets or returns the value of the dateTime attribute of a deleted element.

Syntax:



document.getElementById("ID");

Where ID attribute is the ID assigned to the <del> tag.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>HTML DOM Del Object</title
        <style
            del { 
                color: red; 
            
            ins { 
                color: green; 
            
        </style
    </head
      
    <body
        <h1>GeeksforGeeks</h1
          
        <h2>DOM Del Object</h2>
          
        <p>
            GeeksforGeeks is a <del id = "GFG" 
            datetime = "2018-11-21T15:55:03Z"
            mathematical</del> <ins>computer</ins
            science portal
        </p>
          
        <button onclick="myGeeks()">
            Submit
        </button>
          
        <p id="sudo"></p>
          
        <script>
            function myGeeks() {
                var g = document.getElementById("GFG").dateTime;
                document.getElementById("sudo").innerHTML = g;
            }
        </script>
  
    </body
</html>                                

chevron_right


Output:
Before Click on the button:

After Click on the button:

Example 2: Del 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 Del Object
        </title
          
        <style
            del { 
                color: red; 
            
            ins { 
                color: green; 
            
        </style
    </head
      
    <body
        <h1>GeeksforGeeks</h1
          
        <h2>DOM Del Object</h2>
          
        <button onclick = "myGeeks()">
            Submit
        </button>
          
        <p id="sudo"></p>
          
        <script>
            function myGeeks() {
                var g = document.createElement("DEL");
                var f = document.createTextNode("GeeksforGeeks");
                g.appendChild(f);
                document.body.appendChild(g);
            }
        </script>
    </body>
</html>                                    

chevron_right


Output:
Before Clicking On Button:

Aftwr Clicking On Button:

Supported Browsers: The browser supported by DOM Del 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.