简单教程
提交运行
代码编辑器:
<img src="/static/i/img1.jpg" width="145" height="126" alt="Planets" usemap="#myMap"> </map> <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>
运行结果: