<script>
function light(sw) {
  var pic;
  if (sw == 0) {
    pic = "https://laptrinhtudau.com/wp-content/uploads/2021/12/pic_bulboff.gif"
  } else {
    pic = "https://laptrinhtudau.com/wp-content/uploads/2021/12/pic_bulbon.gif"
  }
  document.getElementById('myImage').src = pic;
}
</script>

<img id="myImage" src="https://laptrinhtudau.com/wp-content/uploads/2021/12/pic_bulbon.gif" width="100" height="180">

<p>
<button type="button" onclick="light(1)">bật đèn</button>
<button type="button" onclick="light(0)">tắt đèn</button>
</p>

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.