这段代码怎么会抛出“Uncaught ReferenceError: $ is not defined”?
我已经检查了 javascript 是否能够被加载。但萤火虫总是显示错误信息。
这是html代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lab 2</title>
<script type="text/javascript" src = "lab2.js"></script>
</head>
<body>
<div id= "chatHeader"><h1>Lab2 - (not yet online) Chat</h1></div>
<div id= "chatContentArea">
</div>
<div id= "chatBottomBar">
<textarea>Leave your message</textarea>
<button>submit</button>
</div>
</body>
</html>
js代码:
$(document).ready(function(){
$('button').click(function(){
var message = $('textarea').val();
alert(message);
})
});