Javascript Reference - HTML DOM Del Object








The Del object represents an HTML <del> element.

Del Object Properties

Property Description
cite Sets or gets the value of the cite attribute
dateTime Sets or gets the value of the datetime attribute

Standard Properties and Events

The Del object supports the standard properties and events.

Example

The following code shows how to get a <del> element by using getElementById():


<!DOCTYPE html>
<html>
<body>
<del id="myDel" cite="http://java2s.com">deleted.</del>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from   ww  w .  j  av  a2s  .  c om-->
    var x = document.getElementById("myDel").cite;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to create a <del> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--  w  ww  . j  ava  2s . c om-->
    var x = document.createElement("DEL");
    var t = document.createTextNode("Some deleted text");
    x.appendChild(t);
    document.body.appendChild(x);
}
</script>
</body>
</html>

The code above is rendered as follows: