Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
div {
  border: 1px solid black;
  padding: 16px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The getElementsByClassName() Method</h2>
<div class="example">
  <p class="child">I am a paragraph.</p>
</div>
<div class="example">
  <p class="child color">I am a paragraph.</p>
  <p class="child color">I am a paragraph.</p>
</div>
<div class="example">
  <p class="child color">I am a paragraph.</p>
  <p class="child color">I am a paragraph.</p>
</div>
<p>Click "Change" to change the size of the first paragraph with classes "child" and "color"
inside the second div element with class="example".</p>
<button onclick="myFunction()">Change</button>
<script>
function myFunction() {
  const elements = document.getElementsByClassName("example")[1];
  elements.getElementsByClassName("child color")[0].style.fontSize = "24px";
}
</script>
</body>
</html>