<!DOCTYPE html> <html> <body> <h1>HTML DOM Attributes</h1> <h2>value 属性</h2> <p>点击开灯按钮可更改图片的 src 属性:</p> <button onclick="myFunction()">开灯</button> <img id="light" src="/static/demo/images/bulboff.gif" width="108" height="180"> <script> function myFunction() { const nodeMap = document.getElementById("light").attributes; nodeMap.getNamedItem("src").value = "/static/demo/images/bulbon.gif"; } </script> </body> </html>