Reputation: 1814
I am getting the following error:
ReferenceError: $ is not defined
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<style>
#navBox {
width: 150px;
height: 150px;
background-color: #004C7E;
}
</style>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<div id="navBox"></div>
<script>
$(document).click(function () {
$("#navBox").effect("shake");
});
</script>
</body>
</html>
Am I using an outdated jquery version? I was trying to follow this guide: http://api.jqueryui.com/shake-effect/
Upvotes: 0
Views: 790
Reputation: 1075587
I expect if you look in your web console, you'll see some 404 errors.
This:
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
...uses a protocol-relative URL. That means if the page was loaded from http://example.com
, the protocol will be http:
; if from https://example.com
, it'll be https:
. And critically, if it's file://c/your/stuff
, then it's file:
and the source doesn't exist.
Using a protocol-relative URL is fine, but if you do, you can't open HTML files directly from your local filesystem and expect them to work. You have to open them through a web server (you can readily install a simple web server on your local system).
Upvotes: 6