mamp wordpress jquery 问题。他们不工作

发布于 2024-10-04 08:54:24 字数 690 浏览 0 评论 0原文

我的 jQuery 函数正在触发,但它们都无法通过普通的 WordPress 安装运行。还有其他人遇到过这个问题吗?

展示这样的示例将非常具有挑战性,因为它是通过框架运行的。

我有一个名为“main.js”的外部 JS 脚本:

<script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.4.4.min.js" type="text/javascript" charset="UTF-8"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/main.js" type="text/javascript" charset="UTF-8"></script>

$(document).ready(function() {

    foo1('.foo1',500);  

    $(".foo2").foo2({
        // foo2
    });
});

function foo1(e,s) {
    // foo1
}

这是正常设置,在托管时可以正常工作。只是在本地主机上,由于某种原因它无法工作。是否有需要设置的 MAMP (OSX) 设置。

My jQuery functions are firing but none of them are working through a vanilla wordpress install. Has anyone else had this problem?

To show an example of this would be quite challenging since it's running through a framework.

I have an external JS script called 'main.js':

<script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.4.4.min.js" type="text/javascript" charset="UTF-8"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/main.js" type="text/javascript" charset="UTF-8"></script>

$(document).ready(function() {

    foo1('.foo1',500);  

    $(".foo2").foo2({
        // foo2
    });
});

function foo1(e,s) {
    // foo1
}

It's normal setup an working when hosted. It's just on localhost that it isn't working for some reason. Is there a MAMP (OSX) setting that needs to be setup.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

祁梦 2024-10-11 08:54:24

由于 js 库冲突,“$”符号在 WordPress 内部不起作用。尝试使用 $.noConflict 来解决此问题,语法如下:

$.noConflict();
jQuery(document).ready(function($) {

   foo1('.foo1',500);  

   $(".foo2").foo2({
    // foo2
   });

});

The '$' sign does not work inside of wordpress by because of conflicting js libraries. Try using $.noConflict to address this problem by using the syntax below:

$.noConflict();
jQuery(document).ready(function($) {

   foo1('.foo1',500);  

   $(".foo2").foo2({
    // foo2
   });

});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文