JQuery.js WordPress冲突 [英] JQuery.js WordPress conflict

查看:141
本文介绍了JQuery.js WordPress冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a WordPress site that uses the jQuery Mega Menu plugin and theme-my-login both call:

<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发生冲突

which causes conflicts with WordPress jquery.js

任何人都可以帮助我解决此问题吗?或至少让我知道为什么会发生这种冲突.

Can anyone can help me fix this? or let me know at least why this conflict happen.

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

The error I get from this conflict is:

Uncaught TypeError: undefined is not a function

推荐答案

您不需要包含自己的jQuery,Wordpress包含了它,但是$名称已保留.

You don't need to include your own jQuery, Wordpress have included it, but the $ name was reserved.

随便打电话:

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

这篇关于JQuery.js WordPress冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆