Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript WordPress中jQuery的问题。jQuery加载但不加载';行不通_Javascript_Php_Jquery_Wordpress - Fatal编程技术网

Javascript WordPress中jQuery的问题。jQuery加载但不加载';行不通

Javascript WordPress中jQuery的问题。jQuery加载但不加载';行不通,javascript,php,jquery,wordpress,Javascript,Php,Jquery,Wordpress,首先,如果我的英语不太清楚,我道歉。 我会尽量简明扼要 正如我在标题中所说,jQuery文件已加载,但它不起作用,我的意思是,它出现在头部(我已经尝试将其放在页脚中),但$function无法识别。 我在这个社区和其他许多地方调查了几天,但没有成功 My functions.php标题: <?php //Load jQuery function loadjQuery() { wp_deregister_script('jquery'); wp_register_script

首先,如果我的英语不太清楚,我道歉。 我会尽量简明扼要

正如我在标题中所说,jQuery文件已加载,但它不起作用,我的意思是,它出现在头部(我已经尝试将其放在页脚中),但$function无法识别。 我在这个社区和其他许多地方调查了几天,但没有成功

My functions.php标题:

<?php
//Load jQuery
function loadjQuery() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', get_template_directory_uri().'/js/jquery.min.js', array(), null);
    wp_enqueue_script('jquery');
}

//Load js
function add_js(){
    wp_register_script('jquery-migrate', get_template_directory_uri().'/js/jquery-migrate.min.js', array("jquery"), null);
    wp_enqueue_script('jquery-migrate');
    wp_register_script('jquery-waypoints', get_template_directory_uri().'/js/jquery.waypoints.min.js', array("jquery"));
    wp_enqueue_script('jquery-waypoints');  
    wp_register_script('jquery-counterup', get_template_directory_uri().'/js/jquery.counterup.min.js', array("jquery"));
    wp_enqueue_script('jquery-counterup');
    wp_register_script('bootstrap', get_template_directory_uri().'/js/bootstrap/js/bootstrap.min.js', array('jquery'));
    wp_enqueue_script('bootstrap');
    wp_register_script('popper', get_template_directory_uri()."/js/popper.min.js"
, array('jquery'));
    wp_enqueue_script('popper');
    wp_register_script('easing', get_template_directory_uri()."/js/easing.min.js", array('jquery'));
    wp_enqueue_script('easing');    
    wp_register_script('typed', get_template_directory_uri().'/js/typed/typed.min.js', array('jquery'));
    wp_enqueue_script('typed');
    wp_register_script('main', get_template_directory_uri().'/js/main.js', array('jquery'), null);
    wp_enqueue_script('main');

}
add_action("wp_enqueue_scripts", "load_stylesheets");
add_action('wp_enqueue_scripts', 'loadjQuery',999);
add_action("wp_enqueue_scripts", "add_js", 999);
add_action('phpmailer_init','send_smtp_email');
?>
我还尝试用jQuery更改所有的“$”元素,并加载jQuery的cdn,但也没有成功


提前感谢

使用jQuery的正确方法是在自动执行的匿名函数中,如下所示:

(function($) {

  $('#preloader').addClass('preloader');
  ...

})(jQuery);

开发人员控制台中的错误是什么?未捕获的TypeError:$(…)。addClass(…)不是函数,但如果我用“$”替换第一个函数jQuery,则错误是:$不是函数,引用错误。因此,如果我用“$”替换所有jquery元素,它仍然不起作用:(你能检查jquery是否真正进入队列吗?我如何检查?至少在开发人员控制台中,除了引用错误之外,我看不到其他任何东西。是的,我已经尝试过了(我的代码在匿名函数中)但我没用编辑:我在匿名函数中限定了每个事件函数,效果很好!谢谢你,伙计!
(function($) {

  $('#preloader').addClass('preloader');
  ...

})(jQuery);