Javascript DOM HTML Emphasized Object get

Introduction

The Emphasized object represents an HTML <em> element.

We can access an <em> element via document.getElementById():

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

Click the button to set the color of em element to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  w  w w  .  j a  v  a2  s.c o m*/
  var x = document.getElementById("myEm");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related