Newer
Older
hello-programmer-world / src / sample / js / change-style.html
<p id="text">文字の色が変わります</p>
<button id="btn">赤にする</button>

<script>
  const text = document.querySelector("#text");
  const btn = document.querySelector("#btn");

  btn.addEventListener("click", () => {
    text.style.color = "red";
    text.style.fontWeight = "bold";
  });
</script>