เพื่อดึงค่า usemap attribute ของ Element <img> ให้ใช้ Property .useMap (ตัว M ใหญ่)
เกี่ยวกับ usemap
Attribute usemap ใช้สำหรับ Client-side Image Maps ซึ่งเชื่อมโยงรูปภาพกับ <map> และ <area> เพื่อสร้างพื้นที่คลิกได้บนรูปภาพ
ตัวอย่างโค้ด
<!DOCTYPE html>
<html>
<body>
<img id="myid" src="/images/html.gif" alt="HTML Map" border="0" usemap="#html" />
<map name="html">
<area id="myarea" shape="circle" coords="154,150,59" href="about.htm?id=company" alt="Team" target="_self">
</map>
<script>
var myVal = document.getElementById("myid").useMap;
document.write("<br>Usemap value: " + myVal);
</script>
</body>
</html>
คำอธิบาย
document.getElementById("myid").useMap— คืนค่า"#html"(ค่า usemap attribute)- Property นี้คืนค่ารวมเครื่องหมาย
#เสมอ
แก้ไขข้อมูลต้นฉบับ: usemap ไม่ได้ใช้ระบุ MIME Type (text/html, text/css) ตามที่กล่าวไว้เดิม — ใคร่ใช้สำหรับ Image Map เท่านั้น