【问题标题】:anchor to div don't work in area shapediv 的锚点在区域形状中不起作用
【发布时间】:2014-02-07 05:16:32
【问题描述】:

我有地图图像区域,例如:

 <area shape="circle" coords="60,59,20"  href="#div1" item="list1">

我使用以下函数来显示/隐藏我的 div:

<!-- jQuery Plugin -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$('[item]').click(function(){
    var item=$(this).attr('item');
    $(".display").hide();
    $("#"+item).show();
    return false;
});
</script> 

我的身体里有

<div id="list1" style="display:none;">Test</div>

我单击区域地图,div 显示正确,但 div 的锚点不起作用。 为什么? 谢谢

【问题讨论】:

    标签: javascript html anchor shape area


    【解决方案1】:

    在你的 div 之前添加一个带有 name="div1" 属性的 a 元素:

    <a name="div1"></a>
    <div id="list1" style="display:none;">Test</div>
    

    这是how anchors works,例如:

    <a href="#anyword">Jump to any place</a>
    ...
    <a name="anyword">Jump to this place</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-26
      • 2019-04-19
      • 2011-02-02
      • 2018-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多