编辑下面的代码:【加编码】
<html> <body> Read about the <a href="/demo/dom_obj_attributes.php" target="_blank">Attr object</a>. <p id="demo">Click the button to display the value of the target attribute of the link above</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var a=document.getElementsByTagName("a")[0]; document.getElementById("demo").innerHTML=a.getAttribute("target"); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂