Javascript Reference - HTML DOM Address Object








The Address object represents an HTML <address> element.

Example

The following code creates an address element first in the body tag and then uses getElementById() to get the address element.


<!DOCTYPE html>
<html>
<body>
<address id="myAdr">
example.com<br>
Box 123, Main Street<br>
UK<!--from   w  w  w.j  a v a  2  s .  c o  m-->
</address>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    var x = document.getElementById("myAdr");
    x.style.color = "blue";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code creates an <address> element by using the document.createElement() method:


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from   w  w  w. j  a  va 2s.c  om-->
    var x = document.createElement("ADDRESS");
    var t = document.createTextNode("Box 123, Main Street, UK");
    x.appendChild(t);
    document.body.appendChild(x);
}
</script>

</body>
</html>

The code above is rendered as follows:





Standard Properties and Events

The Address object supports the standard properties and events.