编辑下面的代码:【加编码】
<html> <body> <img src="/demo/planets.gif" width="145" height="126" usemap="#myMap"> <p>点击按钮创建 IMAGE-MAP 和 AREA 元素并链接到 "venus.htm".</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> function myFunction() { var x = document.createElement("MAP"); x.setAttribute("id", "myMap"); x.setAttribute("name", "myMap"); document.body.appendChild(x); var y = document.createElement("AREA"); y.setAttribute("href", "venus.htm"); y.setAttribute("shape", "circle"); y.setAttribute("coords", "124,58,8"); document.getElementById("myMap").appendChild(y); document.getElementById("demo").innerHTML = " MAP 已创建,你可以点击图片中的金星区域。"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂