代码非常简单,第一行就报错了
$(document).ready(function() {
// Code
});
TypeError: $ is not a function
估计是 $ 冲突了,果然,修改成下面的代码即可
jQuery(document).ready(function($) { // Code });
This is because WordPress may use $ for something other than jQuery, in the future, or now, and so you need to load jQuery in a way that the $ can be used only in a jQuery document ready callback.
这样写的确是良好的习惯,即使不在 wordpress 项目中也应该这样写。
微信关注我哦 👍
我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式