鼠标移动的梯度度在我的文本编辑器中不起作用,但在Codepen中起作用。
https://codepen.io/glittergirl/pen/bjXOYd
我检查了控制台,并提出了:script.js:4 Uncaught ReferenceError:未定义$ 所以我用
/*jslint browser: true*/
/*global $ */
但是仍然出现相同的错误。为什么会这样?
HTML
<script language="JavaScript" type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs
/jquery/3.1.1/jquery.min.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" type="text/css" href="jquery.fullPage.css" />
<link rel="stylesheet" type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.2/
fullpage.css"/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.2/
fullpage.js"></script>
<script>
$(document).ready(function() {
$('#fullpage').fullpage({
css3: false
});
});
</script>
<div class="gradient">
</div>
Mousemove JS
$(".gradient").mousemove(function (event) {
'use strict';
var w = $(this).width(),
pct = 360 * (+event.pageX) / w,
bg = "linear-gradient(" + pct + "deg,#4ac1ff,#795bb0)";
$(".gradient").css("background-image", bg);
});
编辑:在html中对jquery重新排序后,控制台日志不再产生错误,但是代码仍无法在我的代码编辑器中工作