代码之家  ›  专栏  ›  技术社区  ›  scrot

图像映射:点击以在屏幕上回显/打印文本

  •  6
  • scrot  · 技术社区  · 17 年前

    是否可以点击图像映射的一部分并打印出一些文本,无论是 alt 或 title 其价值 <area> 在页面的某个地方标记?

    谢谢。

    1 回复  |  直到 17 年前
        1
  •  13
  •   Colin    17 年前

    HTML:

    <map name="Map" id="Map">
      <area shape="rect" coords="32,36,222,109" href="#" alt="hi" />
      <area shape="rect" coords="246,45,420,110" href="#" alt="alt" />
      <area shape="rect" coords="456,45,585,111" href="#" />
      <area shape="rect" coords="627,44,768,118" href="#" />
    </map>
    

    jQuery:

    <script type="text/javascript">
     $(function(){
      $('map area').click(function(){
       alert($(this).attr('alt'));
      });
     });
    </script>