Javascript DOM HTML Address Object get

Introduction

The Address object represents an HTML <address> element.

We can access an <address> element by using getElementById():

var x = document.getElementById("myAdr");

Click the button to set the text color of the address to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<address id="myAdr">
Example.com<br>
Box 1234, Main Street<br>
USA//w  ww .ja va2s .c  om
</address>

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

<script>
function myFunction() {
  var x = document.getElementById("myAdr");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related