Javascript DOM HTML Italic Object get

Introduction

The Italic object represents an HTML <i> element.

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

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

Click button to set the color of <i> to red.

View in separate window

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

<script>
function myFunction() {// ww  w.ja va  2s  . co  m
  var x = document.getElementById("myItalic");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related