jQuery の実装に問題がありました。特に、Code Academy からこの演習を複製する際に苦労しました。スタック オーバーフローに関するこの他の質問から、<script>
参照する jQuery.js を<script>
ローカル JavaScript ファイルを参照する前に配置し$(document).ready();
て認識させる必要があることを理解しています。
そのため、ここに index.html があります。
<!DOCTYPE html>
<html>
<head>
<title>Behold!</title>
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css'/>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<script type='text/javascript' src='index.js'></script>
</head>
<body>
<div id="menu">
<h3>jQuery</h3>
<div>
<p>jQuery is a JavaScript library that makes your websites look absolutely stunning.</p>
</div>
<h3>jQuery UI</h3>
<div>
<p>jQuery UI includes even more jQuery goodness!</p>
</div>
<h3>JavaScript</h3>
<div>
<p>JavaScript is a programming language used in web browsers.</p>
</div>
</div>
</body>
</html>
そして、ここに私のindex.jsがあります:
$(document).ready(function() {
$("#menu").accordion({collapsible: true, active: false});
});
Chrome と IE の両方で、これは完全に空白のページとして表示され、jQueryaccordion
やテキストの痕跡はまったくありません。何か見落としがある場合はお知らせください - 本当に助かります。ありがとう!