Javascript Reference - HTML DOM Ins Object








The Ins object represents an HTML <ins> element.

Ins Object Properties

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

Standard Properties and Events

The Ins object supports the standard properties and events.

Example

We can access an <ins> element by using getElementById().


<!DOCTYPE html>
<html>
<body>
<ins id="myIns" cite="http://example.com">This is an inserted text.</ins>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w .j  a  va2s  .com-->
    var x = document.getElementById("myIns").cite;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

We can create an <ins> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--  w  w  w.jav  a2 s .c  o  m-->
    var x = document.createElement("INS");
    var t = document.createTextNode("Some inserted text");
    x.appendChild(t);
    document.body.appendChild(x);
}
</script>

</body>
</html>

The code above is rendered as follows: