【问题标题】:Maphilight plugin not working in Wordpress due to jQuery conflict由于 jQuery 冲突,Maphilight 插件无法在 Wordpress 中运行
【发布时间】:2011-04-26 15:21:05
【问题描述】:

我在美国地图上使用 maphilight 插件,这样当鼠标悬停时,状态会改变颜色。

(http://plugins.jquery.com/project/maphilight

带演示:

http://davidlynch.org/js/maphilight/docs/demo_usa.html)

我的 header.php 中有以下内容(我正在使用 wordpress):

<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery-1.2.3.pack.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.metadata.min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/adventure-journal-child/js/jquery.maphilight.js"></script>

在我安装 Styles with Shortcodes (SWS) http://plugins.righthere.com/styles-with-shortcodes/ 之前,它运行良好,以便能够添加也使用 JQuery 的选项卡和工具提示。

两人引发了冲突。因此,一旦删除了与 maphilights 关联的 jQuery 代码,我的选项卡和工具提示就会工作。我一直在阅读这方面的内容,并意识到将代码加载到标题中并不理想。 我的问题是:如何在不引起冲突的情况下让 maphilight 工作?

我试过了:

 <script type="text/javascript">
    jQuery.noConflict();
    jQuery(function() {
        jQuery('.map').maphilight({fade: false}); /*set true for fading hover effect*/
           });
</script>   

maphilight 插件可以使用与我的 Styles with Shortcodes 相同的 jQuery 吗?那么我该怎么做呢?

我想我需要在functions.php 中使用wp_enqueue_script,但我不确定如何去做。

我的最终目标是能够在地图上滚动一个状态,它会突出显示并弹出一个工具提示,其中包含文本和链接。 非常感谢!

【问题讨论】:

    标签: jquery wordpress


    【解决方案1】:

    解决这个问题有点困难,因为这些是付费插件,我们在您的链接中看不到冲突,但您可以尝试的一件事是更新您的 jquery,您目前使用的是 1.4.2,但它们是1.5.2

    http://code.jquery.com/jquery-1.5.2.min.js

    【讨论】:

    • 感谢您的回复。我会试试的。我把这条线: 重新打开,我的亮点重新打开,现在我的标签被禁用。这是我正在玩的页面:militarywom.com/find-an-installation
    【解决方案2】:

    您最好改用wp_enqueue_script 函数。在了解该功能之前,我在几个 WordPress 网站上遇到了类似的问题。

    【讨论】:

      猜你喜欢
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多