Why does jQuery work on codecademy.com, but not on computer?


#1

I have tried several times to run codes that work on codecademy.com on my computer, but for unknown reasons, the mini-programs do not work.
Assume the following files:

index.html:
<!DOCTYPE html>
<html>
	<head>
		<title>Result</title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script type='text/javascript' src='script.js'></script>
	</head>
	<body>
        <div></div>   
	</body>
</html>

stylesheet.css:
div {
    height: 50px;
    width: 300px;
    border-radius:0;
    background-color: #2C7CC3;
} 

script.js:
$(document).ready(function()
{
    $('div').height("200px");
    $('div').width("200px");
    $("div").css("border-radius","10px");
});

When I run the code on my computer it does not work, however, on jsfiddle or codecademy.com it does. Why?
Thank you.


#2
<!DOCTYPE html>
<html>
	<head>
		<title>Result</title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script type='text/javascript' src='script.js'></script>
	</head>
	<body>
        <div></div>   
	</body>
</html>

#3

You need to link to a jQuery file. Download it from here - https://jquery.com/download/ and include it in your <head> before the script.js.

In Codecademy or JSFiddle, these files come pre-loaded without much hassle.