【发布时间】:2017-09-27 07:59:00
【问题描述】:
在 Wordpress 中使用钩子 wp_enqueue_script 覆盖 jQuery 版本,但它不起作用。而且我需要两个 jquery。
我想为网站定制添加新的 jquery 版本。
但是当我添加新版本的 jquery 时,旧版本的 jquery 功能不起作用
函数.php:
function themeslug_enqueue_script(){
wp_enqueue_script('child_theme_script_handle', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js',
array( 'jquery' ), '3.2.1', true );
wp_enqueue_script( 'my-great-script', get_stylesheet_directory_uri() . '/core/assets/js/multi-vendors.js',
array( 'jquery' ), '1.0', true );
}
add_action('wp_enqueue_scripts', 'themeslug_enqueue_script');
jQuery.js:
$(document).ready(function(){
alert('Hello');
});
某些功能无法正常工作。比如滑块。
【问题讨论】:
-
在 wordpress 中你必须使用 jQuery 而不是 $
-
不工作,同样的问题
-
我们可以查看网站以检查是否所有内容都包含在内
-
我在本地环境中工作
标签: javascript php jquery wordpress