Javascript DOM HTML Cite Object

Introduction

The Cite object represents an HTML <cite> element.

We can access a <cite> element by using getElementById():

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

Click the button to set the color of the citation to red.

View in separate window

<!DOCTYPE html>
<html>
<body>
<img src="image1.png" width="100" height="100" alt="The circle">
<p><cite id="myCite">The Circle</cite> by demo2s. Painted in 2020.</p>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*ww w. jav  a 2  s . c  o  m*/
  var x = document.getElementById("myCite");
  x.style.color = "red";
}
</script>

</body>
</html>



PreviousNext

Related