复制到Dreamweaver

时间:2016-10-23 03:23:35

标签: javascript jquery html dreamweaver

我一直试图自己解决这个问题,而我却无法弄清楚我做错了什么。但是当我尝试在Dreamweaver中使用它时,这个jsfiddle:http://jsfiddle.net/3964w/3/完全停止工作。

这是我的HTML代码,如果有帮助的话。我对此感到很失落,我认为应该很容易。如果有人能解释我做错了什么,我将非常感激。

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>testing jquery</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script>

var mouseX = 0, mouseY = 0, limitX = 150-15, limitY = 150-15;
$(window).mousemove(function(e){
  var offset = $('.container').offset();
   mouseX = Math.min(e.pageX - offset.left, limitX);
   mouseY = Math.min(e.pageY - offset.top, 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);

</script>    

</head>

<body>

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

</body>

</html>

2 个答案:

答案 0 :(得分:1)

您是从CDN还是本地目录调用jQuery?如果来自CDN,除非从服务器(如localhost)运行页面,否则它将无法工作。因此,如果您没有设置本地服务器,请下载jQuery副本并将其放在您放置JavaScript文件的目录中,并从那里调用它。

或使用此

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

或将您的代码写入文档就绪函数

<script type="text/javascript"> 
$(document).ready(function()
{ /* Your Code Here */ });
 </script>

答案 1 :(得分:0)

缺少style.css,

我将替换

(require '[clojure.data.json :as json]) (require '[clojure.java.io :as java]) (def structure (atom [])) (defn do-it! [xform path] (with-open [r (java/reader path)] (doseq [line (line-seq r)] (swap! structure conj (xform line))))) (defn xf [line] (-> (json/read-str line) (get-in ["experiments" "results"]))) (do-it! xf "file.json") (take 10 @structure)

通过

ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js