6

The code works in Codecademy but doesn't seem to work in Adobe Brackets IDE. Greatly appreciate any help on this issue!

HTML File

<!DOCTYPE html>
<html>
    <head>
        <title>Testing</title>
        <link type="text/css" rel="stylesheet" href="stylesheet.css">
    </head>

    <body>
        <div></div>
        <script src="script.js"></script>
    </body>
</html>

CSS File

div{
    height: 100px;
    width: 100px;
    background-color: aqua;
}

Javascript File

var main = function(){
    $('div').click(function(){
        $('div').hide();
    });
};

$(document).ready(main);
Anthony
  • 34,084
  • 23
  • 90
  • 154
Rafilson
  • 101
  • 2
  • 7

2 Answers2

1

You've not included jQuery in your document.

http://jquery.com/download/

Via CDN:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

If you open your JavaScript console you'd likely see an error telling you that $ is not defined.

Oka
  • 14,862
  • 5
  • 34
  • 46
1

check your folder structure. there is nothing to do with the editor when you are including js files.

one more thing your code seems a jQuery code and to make it run you will need jQuery library file included before your script.js file. to use jQuery functions in your code you need to add the functions library first.

check code below

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
 <script src="script.js"></script>
Nilesh Mahajan
  • 3,378
  • 18
  • 34