Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Attributes</h1> <h2>The getNamedItem() Method </h2> <img id="light" src="pic_bulbon.gif" width="100" height="180"> <p>The value of the scr attribute is:</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>