为什么美元符号不能用作 Wordpress 中 jQuery 的替代品? [英] Why cant Dollar symbol be used as an alternative fo jQuery in Wordpress?

查看:31
本文介绍了为什么美元符号不能用作 Wordpress 中 jQuery 的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在 wordpress 中使用 jQuery,为什么我们不能使用$"?通常$"是 jQuery 的替代品,对吗?但在 Wordpress 中,它显示 "$" 不是函数.我不明白为什么会这样.谁能解释一下?

Why can't we use "$" instead if jQuery in wordpress? Usually "$" is the alternative of jQuery right? But in Wordpress it shows "$" is not a function. I dont get why is that so. Can anyone explain?

推荐答案

查看此网页中的提示 5:使用 jquery 和 wordpress 的 5 个技巧:

Have a look at tip 5 in this web page: 5 Tips for using jquery with wordpress:

重要的是要知道附带的 jQuery 版本WordPress 自动调用 jQuery.noConflict();函数,其中首先将 $ 变量的控制权交还给任何一个库实施了它.如果您正在加载 jQuery 的不同副本,您将需要手动调用 jQuery.noConflict();,如有必要,从您的 JavaScript 文件.

It is important to know that the version of jQuery that comes with WordPress automatically calls the jQuery.noConflict(); function, which gives control of the $ variable back to whichever library first implemented it. If you are loading a different copy of jQuery, you'll need to manually call jQuery.noConflict();, if necessary, from one of your JavaScript files.

希望能帮到你.

这篇关于为什么美元符号不能用作 Wordpress 中 jQuery 的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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