2017-08-30 13 views
0

オンラインコースでは、jQueryとJavaScriptを使用するWebページを作成する必要があります。 JavaScriptコードを追加しているので、 'START'というテキストが表示されたWebページのボタンをクリックすると消えてしまいますが、私のWebページはそれを実行していません。htmlのjavascriptコードに崇高なテキストでアクセスできません

HTMLコード:JavaScriptのコード

<head> 
    <link rel = 'stylesheet' type = 'text/css' href = 'memory_game.css'> 
    <script src="C:\Users\Fabian\Documents\sublime\jquery-3.2.1.min"></script> 
    <script type="text/javascript" src="memory_game.js"></script> 
    <title>Concentration - Memory Game </title> 

    <div class = headings> 
     <h1>CONCENTRATION </h1> 
     <h2>The shnazzy, feature-packed memory game! </h2> 
    </div> 

</head> 

<body> 

    <div class = 'rules'> 
     <p>RULES: </p> 
      <ol> 
       <li>The game consists of 16 cards on a 4 by 4 grid </li> 
       <li>Initially, the cards will be faced up for a short period of time and, and will consist of 8 pairs, each with both cards having the same symbol </li> 
       <li>Once these cards are faced back down, your objective is to try and remember which cards contained matching symbols</li> 
       <li>Once you click one card, guess which one is paired with the card you just clicked, and if you get it correct, your score goes up by 1 </li> 
       <li>If you guess a pair incorrectly, the two cards you click will be faced back down </li> 
       <li>When you find all matching pairs, you win, and you get the option to play again </li> 
       <li>Your performance rating at the end of the game will be a star rating of 1 to 3, which will be based on how many incorrect guesses you make, and how long it takes for you to win the game, for a timer will be shown during the game </li> 
      </ol> 
    </div> 

    <div class = 'grid'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 
     <img src = 'https://balancebest.co.uk/33349-home_default/flutter-fetti-orange-block-2.jpg' alt = 'block'> 

    </div> 

    <div id = 'startButton'> 
     <button>START</button> 
    </div> 

    <div id = 'reStartButton'> 
     <button>RESTART</button> 
    </div> 

    <div id = 'score'> 
     <p>SCORE: </p> 
    </div> 

</body> 

$('#startButton').click(function() { 
    $('##startButton').hide(); 
}); 

CSSを心配する必要はありません、それは心配するだけJavaScriptとHTMLですので、約。

アドバイスがありましたら、この質問にお答えください。

+0

ことdocument.readyイベントハンドラ( '$(関数の中であなたのjQueryのコードをラップする必要がありますありがとう(){/ *あなたのコードはここに... * /}); ')第2に、 '## startButton'はセレクタではなく、代わりに'#startButton'を使います。最後に、ブラウザがローカルファイルシステムからJSファイルをロードするのをブロックしている可能性があるので、コンソールをダブルチェックしてください。 –

+0

大丈夫です、ありがとう、ありがとう –

答えて

1

##startButtonは、任意の要素を選択していないので、JSコードは、まず

$('#startButton').click(function() { 
    $('#startButton').hide(); 
}); 
関連する問題