Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Attributes</h1>
<h2>The value Property</h2>
<p>Click to change the src attribute of the image:</p>
<button onclick="myFunction()">Click</button>
<img id="light" src="pic_bulboff.gif" width="100" height="180">
<script>
function myFunction() {
  const nodeMap = document.getElementById("light").attributes;
  nodeMap.getNamedItem("src").value = "pic_bulbon.gif";
}
</script>
</body>
</html>