x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Attributes</h1>
<h2>getNamedItem() 方法</h2>
<img id="light" src="/i/pic/bulbon.gif" width="108" height="180">
<p>scr 属性的值是:</p>
<p id="demo"></p>
<script>
const nodeMap = document.getElementById("light").attributes;
let value = nodeMap.getNamedItem("src").value;  
document.getElementById("demo").innerHTML = value;
</script>
</body>
</html>