IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]jQuery—$ is not a function

    wangshuxuncom发表于 2016-03-08 09:19:24
    love 0

            昨天编写代码,在使用jQuery获取input值时浏览器控制台显示“$ is not a function”,查看自己写的代码,发现没有写错,于是查找各种资料,终于将问题解决了:

    If you are trying to add your own jQuery code to WordPress, and have had the error “$ is not a function” show up on Firebug, here is the fix:
    Convert all dollar signs ($) to ‘jQuery’.The dollar sign is reserved in WordPress for the Prototype library, which is why it errors out. 

            其实非常简单:$已经在其他包中当做了一个变量,别忘了一个页面可以引入多个不同的JavaScript脚本库,怎么解决呢——将$换成jQuery即可,例如:把“$('userName').val();”改成“jQuery('userName').val();”



沪ICP备19023445号-2号
友情链接