【问题标题】:JQuery.js WordPress conflictjQuery.js WordPress 冲突
【发布时间】:2014-06-22 14:35:53
【问题描述】:

我有一个 WordPress 网站,它使用 jQuery Mega Menu 插件theme-my-login 都调用:

<script type='text/javascript'src='http://localhost/wadhaa/dynamic/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script>

在我的头部分:

<?php
    /* Always have wp_head() just before the closing </head>
     * tag of your theme, or you will break many plugins, which
     * generally use this hook to add elements to <head> such
     * as styles, scripts, and meta tags.
     */
    wp_head();
   ?>

我必须包括:

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

这会导致与 WordPress jquery.js 发生冲突

谁能帮我解决这个问题?或者至少让我知道为什么会发生这种冲突。

我从这个冲突中得到的错误是:

Uncaught TypeError: undefined is not a function

【问题讨论】:

标签: jquery wordpress


【解决方案1】:

你不需要包含你自己的 jQuery,Wordpress 已经包含了它,但是 $ 名称被保留了。

只要打电话:

jQuery(function($) {
    $('#what_ever_you_want').do_something();
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    相关资源
    最近更新 更多