jQuery maphilight 不工作

Posted

技术标签:

【中文标题】jQuery maphilight 不工作【英文标题】:jQuery maphilight not working 【发布时间】:2017-06-19 19:02:45 【问题描述】:

我错过了什么?我正在使用David Lynch maphilight 插件,并且一直在将我的代码与此页面进行比较以进行故障排除,但两天后,我仍然遇到问题。当我将鼠标悬停在(甚至单击)映射图像的任何部分时,颜色不会显示。链接按预期工作。

我的脚本调用是:

   <head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.maphilight.js"></script>
    <script type="text/javascript">$(function() 
        $('.AMGCmap1').maphilight();
    </script>
   </head>

而img和map的代码是:

            <div>
                <img class ="map" id ="AMGCmap1" src="Images\AMGC Logo Big.png"  usemap="#AGMCmap" border="15">

                <map name="AGMCmap">
                    <area shape="poly" coords="61,432, 58,346, 71,285, 148,287, 164,345, 166,432" href="news.html"  title= "News" data-maphilight='"strokeColor":"0000ff","strokeWidth":5,"fillColor":"ff0000","fillOpacity":0.6' >
                </map>

            </div>

我尝试在函数中使用 img ID 和“'.map'”,但没有发现任何区别。其他人有这样的问题吗?

我目前正在使用 Chrome,如果这有帮助的话。

【问题讨论】:

【参考方案1】:
<img class ="map" id ="AMGCmap1" ...>

在这里,您有一个 id,同时您正在脚本中调用一个类。

$('.AMGCmap1').maphilight();

这可能是问题所在。 将 HTML 中的 id 编辑为一个类:

<img class ="map AMGCmap1" ...>

或者在你的脚本中调用一个 id:

$('#AMGCmap1').maphilight();

不管怎样,即使我已经仔细检查了我的脚本,我也遇到了同样的问题,如果你能在修复后让它工作,请告诉我。

【讨论】:

以上是关于jQuery maphilight 不工作的主要内容,如果未能解决你的问题,请参考以下文章

HTML JQuery Maphilight 没有突出显示 - 不知道为啥

带有弹出窗口的 Maphilight jQuery

Jquery Maphilight 打印问题

Maphilight 与 IE9 中的 Jquery 选项卡发生冲突

jQuery maphilight 通过单击将区域设置为 alwaysOn

jQuery Maphilight。在突出显示新之前切换alwaysOn