在functions.php中排队脚本后,Javascript无法在wordpress上运行

时间:2014-11-07 03:43:43

标签: javascript jquery wordpress

我想添加一个javascript文件,但它不起作用。我正在使用Avada主题。我把它放在我的functions.php文件的顶部。我保存了但是我没有在页面的源代码中看到它。我正在尝试让脚本在此页面上运行:http://192.185.2.154/~sogo/tempsourceoneevents.com/exhibitor-services/build-a-booth/

functions.php中的代码

<?php

function my_scripts_method() {
    wp_enqueue_script(
        'custom-script',
        get_template_directory_uri() . '/js/bab.js',
        array( 'jquery' )
    );
}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

我的问题的答案是@adeneo的评论,我需要编辑我的javascript文件

&#34;不,你可以用jQuery替换$(document).ready(function($){...});在Wordpress中,它锁定了moneyign的值,因此你可以在DOM就绪函数中使用dollarign。&#34;

1 个答案:

答案 0 :(得分:-2)

试试这段代码..

您需要先添加jquery库

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script type="text/javascript" src="http://192.185.2.154/~sogo/tempsourceoneevents.com/wp-content/uploads/bab.js"></script>