首先你需要创建一个图像映射(https://www.w3schools.com/tags/tag_map.asp)
他们是一个图像(http://imagemap-generator.dariodomi.de/)创建<area>
标签的工具。
示例HTML:
<map name="planetmap">
<area id="first" shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area id="second" shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area id="third" shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
例的JavaScript:
$("area #first").click(function() {
alert("Click!");
}
$("area #second").click(function() {
alert("Click!");
}
为了更好的代码风格,你也可以使用https://api.jquery.com/each/
要命,我已经错过了我生命中的图像映射..非常感谢!! –
@AndreaBiagioni欢迎您!图像地图是** NOT **响应。但是你可以添加这个库来使其具有代表性。 [点击此处查看github资源库](https://github.com/stowball/jQuery-rwdImageMaps) – Pommesloch