TJeffer TJeffer - 3 years ago 167
HTML Question

Jsfiddle won't work when copying into Dreamweaver

I've been trying to solve this by myself, and I just can't figure out what I'm doing wrong. But this jsfiddle: completely stops working when I try to work with it in Dreamweaver.

Here is my html code, if that helps. I'm feeling so lost on this, and I think it should be pretty easy. If someone could explain what I'm doing wrong I would be very grateful.

<!doctype html>
<meta charset="UTF-8">
<title>testing jquery</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<script src="//"></script>


var mouseX = 0, mouseY = 0, limitX = 150-15, limitY = 150-15;
var offset = $('.container').offset();
mouseX = Math.min(e.pageX - offset.left, limitX);
mouseY = Math.min(e.pageY -, limitY);
if (mouseX < 0) mouseX = 0;
if (mouseY < 0) mouseY = 0;

// cache the selector
var follower = $("#follower");
var xp = 0, yp = 0;
var loop = setInterval(function(){
// change 12 to alter damping higher is slower
xp += (mouseX - xp) / 12;
yp += (mouseY - yp) / 12;
follower.css({left:xp, top:yp});

}, 30);




<div class="centerdiv">
<div class="container">
<div id="follower"></div>



Answer Source

Are you calling jQuery from a CDN or a local directory? If from a CDN it won't work unless the page is being run from a server, like localhost. So if you don't have a local server set up then download a copy of jQuery and put it inside the directory where you are putting JavaScript files and call it from there.

Or USe this

<script src=""></script>

or write your code inside document ready function

<script type="text/javascript"> 
{ /* Your Code Here */ });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download