Object Expected error, javascript, jQuery

泪湿孤枕 提交于 2019-12-23 22:38:09

问题


I'm getting an object expected error in a javascript file. In this case does it mean that the jQuery files aren't included properly?

The line that is causing the error is...

$(function () {

The error in the browser is...

Message: Object expected
Line: 6
Char: 1
Code: 0

回答1:


It's possible - if the files weren't included, then the $ variable would indeed not be an object where one was expected. "Object expected" errors usually mean that you have a variable that is null/undefined and then try to call methods on it.

I'd try to find out if this is the case with a simple alert($); and see whether the result is undefined (bad) or something else (probably good).



来源:https://stackoverflow.com/questions/4679459/object-expected-error-javascript-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!