我有一个图像地图,想跟踪它在 javascript 中被点击的次数,但我不知道如何记录点击次数。
<p>
<img src="image.png" alt="missing" width="396" height="376" border="0" usemap="#thatPageMap" />
<map name="imageMap" id="thatPageMap">
<area shape="poly" coords="0,376,-3,269,50,251,60,234,71,225,76,192,69,178,44,127,50,82,73,62,94,48,69,46,108,30,145,20,162,29,162,16,183,34,193,41,228,35,247,38,225,47,242,47,279,53,306,78,324,117,326,150,335,179,327,200,327,221,351,234,357,263,393,275,394,378" href="thatpage.com" alt="Refresh" />
</map>
</p>
上面是图像映射,下面是 javascript 和带有计数 ID 的段落。
<script type="text/javascript">
var count;
document.getElementById("counted").innerHTML = "This has been clicked " + count + " times.";
</script>
<p id="counted"></p>
每次单击图像映射时,如何增加变量计数?