每当我尝试将最新版本的jQuery加载到我的网站时,我都会在Google Chrome控制台中收到此错误;
Uncaught TypeError: object is not a function
我觉得很奇怪,因为我正在做的就是加载。
<head>
<title>Home</title>
<link href = "style.css" rel = "stylesheet">
<link rel = "shortcut icon" href = "\images\design\logo.ico" type = "image/x-icon"/>
<script src = "\script\messageSender.js"> </script>
<script src = "\script\currentTime.js"> </script>
<script src = "\libraries\jQuery.js"> </script>
<div class = "header" id = "header">
<a href = "/">
<img src = "\images\design\header.png" alt = "Header" width = "467" height = "113" title = "Home">
<a>
</div>
<div class = "menu">
<a href = "/">Home</a>
<a href = "/about.html">About</a>
<a href = "/software.html">Software</a>
<a href = "/mods.html">Mods</a>
<a href = "/contact.html">Contact</a>
</div>
</head>
messageSender类
function userAlert(Message){
alert(Message);}
currentTime类
function getYear() {
Date = new Date
Year = Date.getYear()
var Copy = '©';
if (Year < 1900) {
Year = Year + 1900
document.write(Copy + " " + Year + " " + "Trevi Awater")
} else {
return;
}
}
答案 0 :(得分:0)
不推荐使用getYear(),请尝试使用getFullYear()。
答案 1 :(得分:0)
我怀疑这可能发生了(但是我不知道这些类的用法我不能确定这是实际的错误),因为你把那些js文件称为类。
var x = new getYear(); // x is an object
// when trying to call the object as function
x(); // Uncaught TypeError: object is not a function
答案 2 :(得分:0)
更改脚本包含的堆栈顺序:
<script src = "\libraries\jQuery.js"> </script>
<script src = "\script\messageSender.js"> </script>
<script src = "\script\currentTime.js"> </script>