這是我第一次嘗試使用jQuery和我試圖當文檔準備添加事件之前,但每次它說:
「$使用之前定義「。
我不知道如何解決它。我在網上嘗試了不同的解決方案,但找不到任何解決方案。真的不知道我做錯了什麼。
我引用的HTML文件JS文件這樣
<!DOCTYPE html>
<html>
<head>
<title>Experimenting with Javascript</title>
<script type="text/javascript" src="script.js"></script>
<link type="text/css" rel="stylesheet" href="main.css" />
</head>
,這是我的腳本
$(document).ready(function() {
"use strict";
$('div').mouseenter(function() {
$(this).animate({
height: '+=10px'
});
});
});
你需要在你的頁面使用它[包括jQuery庫](http://learn.jquery.com/about-jquery/how-jquery-works/)! – Bergi 2014-11-05 19:13:06
你在哪裏添加jQuery? – 2014-11-05 19:13:32
如果你甚至不知道如何使用庫,我會建議不要使用'「use strict」;',如果你沒有經驗,可能會導致問題(參見[this](https:// bugzilla)。 mozilla.org/show_bug.cgi?id=579119),甚至亞馬遜也搞砸了)。 – blex 2014-11-05 19:18:28