wordpress中如何调用jquery

最近在制作Wordpress主题,在主题中使用jquery时 控制台报错jQuery is not defined $ is not defined
这是因为 wordpress 为了避免冲突 加上了 jQuery.noConflict();
解决方法:
<?php wp_head(); ?>
在主题文件header.php中找到wp_head(),修改为:
<?php wp_enqueue_script('jquery'); wp_head(); ?>
这样就调用
在后面就可以 使用wordpress 中自带的jquery 了
jQuery(document).ready(function ($) {
///do something
})
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/939/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。


共有 0 条评论