所以我用疯子谷歌搜索并且无法弄清楚为什么这不起作用而且我得到了“未捕获的ReferenceError:$未定义”错误。我首先拥有我的JS脚本,并将我的脚本放在底部,但完全丢失了。这里有什么帮助吗?
<html>
<head>
<style type="text/css">
.day {
background-color:#000;
}
.sunset {
background-color:red;
}
.night {
background-color:green;
}
</style>
<script type=”text/javascript” src=”lib/jquery.min.js”></script>
</head>
<body>
<div id="one" style="padding:4px;border:1px #000;">Schedule Box</div>
<script type="text/javascript">
// Change background depending on user’s time
function applyclass()
{
var d = new Date();
var n = d.getHours();
if (n > 19)
// If time is 7PM or later apply night theme to ‘body’
$('body').addClass('night');
else if (n > 16 && n < 19)
// If time is between 4PM – 7PM sunset theme to ‘body’
$('body').addClass('sunset');
else
// Else use ‘day’ theme
$('body').addClass('day');
}
window.onload = applyclass;
</script>
</body>
</html>
答案 0 :(得分:10)
您使用了错误""
更改此内容:
<script type=”text/javascript” src=”lib/jquery.min.js”></script>
要:
<script type="text/javascript" src="lib/jquery.min.js"></script>