1

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やテキストの痕跡はまったくありません。何か見落としがある場合はお知らせください - 本当に助かります。ありがとう!

4

2 に答える 2

0

これ:

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.j" type="text/javascript"></script>

これでなければなりません:

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
于 2013-05-22T05:47:47.470 に答える