Javascript DOM HTML Address Object create

Introduction

The Address object represents an HTML <address> element.

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

var x = document.createElement("ADDRESS");

Click the button to create an ADDRESS element with some text.

View in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w ww  . java2  s . c o  m
  var x = document.createElement("ADDRESS");
  var t = document.createTextNode("Appt 1234, Main Street, USA");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related