对象预期错误,JavaScript,jQuery [英] Object Expected error, javascript, jQuery

查看:80
本文介绍了对象预期错误,JavaScript,jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javascript文件中收到对象预期的错误.在这种情况下,这是否意味着未正确包含jQuery文件?

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

推荐答案

有可能-如果不包含文件,则$变量确实不是预期的对象. 预期对象"错误通常表示您拥有一个null/undefined变量,然后尝试在其上调用方法.

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.

我会尝试使用简单的alert($);来确定是否是这种情况,并查看结果是undefined(不好)还是其他(可能是好的).

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).

这篇关于对象预期错误,JavaScript,jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆