Javascript 如何从这段代码创建本地网站文件?
因此,我最近决定重新开始使用HTML和CSS以及一些JS。。 我只是需要修改一下,因为我以前经常这么做 我发现这段代码在网上被截取到这个项目上,看起来很有趣,但由于某些原因它不起作用 源代码HTML:Javascript 如何从这段代码创建本地网站文件?,javascript,html,css,Javascript,Html,Css,因此,我最近决定重新开始使用HTML和CSS以及一些JS。。 我只是需要修改一下,因为我以前经常这么做 我发现这段代码在网上被截取到这个项目上,看起来很有趣,但由于某些原因它不起作用 源代码HTML: <link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> <link href='http://fonts.googleapi
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Exo+2:900' rel='stylesheet' type='text/css'>
<div id="wrapper">
<div id="wheel">
<div id="inner-wheel">
<div class="sec"><span class="fa fa-bell-o"></span></div>
<div class="sec"><span class="fa fa-comment-o"></span></div>
<div class="sec"><span class="fa fa-smile-o"></span></div>
<div class="sec"><span class="fa fa-heart-o"></span></div>
<div class="sec"><span class="fa fa-star-o"></span></div>
<div class="sec"><span class="fa fa-lightbulb-o"></span></div>
</div>
<div id="spin">
<div id="inner-spin"></div>
</div>
<div id="shine"></div>
</div>
<div id="txt"></div>
</div>
源代码JS:
//set default degree (360*5)
var degree = 1800;
//number of clicks = 0
var clicks = 0;
$(document).ready(function(){
/*WHEEL SPIN FUNCTION*/
$('#spin').click(function(){
//add 1 every click
clicks ++;
/*multiply the degree by number of clicks
generate random number between 1 - 360,
then add to the new degree*/
var newDegree = degree*clicks;
var extraDegree = Math.floor(Math.random() * (360 - 1 + 1)) + 1;
totalDegree = newDegree+extraDegree;
/*let's make the spin btn to tilt every
time the edge of the section hits
the indicator*/
$('#wheel .sec').each(function(){
var t = $(this);
var noY = 0;
var c = 0;
var n = 700;
var interval = setInterval(function () {
c++;
if (c === n) {
clearInterval(interval);
}
var aoY = t.offset().top;
$("#txt").html(aoY);
console.log(aoY);
/*23.7 is the minumum offset number that
each section can get, in a 30 angle degree.
So, if the offset reaches 23.7, then we know
that it has a 30 degree angle and therefore,
exactly aligned with the spin btn*/
if(aoY < 23.89){
console.log('<<<<<<<<');
$('#spin').addClass('spin');
setTimeout(function () {
$('#spin').removeClass('spin');
}, 100);
}
}, 10);
$('#inner-wheel').css({
'transform' : 'rotate(' + totalDegree + 'deg)'
});
noY = t.offset().top;
});
});
});//DOCUMENT READY
//设置默认度数(360*5)
var度=1800;
//点击次数=0
var=0;
$(文档).ready(函数(){
/*车轮自旋函数*/
$('#spin')。单击(函数(){
//每单击一次添加1
点击++;
/*将次数乘以单击次数
生成1-360之间的随机数,
然后添加到新的学位*/
var newDegree=点击次数*degree;
var extraDegree=Math.floor(Math.random()*(360-1+1))+1;
totalDegree=新度+额外度;
/*让我们使旋转btn每小时倾斜一次
截面边缘到达的时间
指示器*/
$('#wheel.sec')。每个(函数(){
var t=$(本);
var-noY=0;
var c=0;
var n=700;
var interval=setInterval(函数(){
C++;
如果(c==n){
间隔时间;
}
var aoY=t.offset().top;
$(“#txt”).html(aoY);
控制台日志(aoY);
/*23.7是所使用的最小偏移量
每一个部分都可以以30度的角度得到。
如果偏移量达到23.7,我们就知道了
它有30度角,因此,
与自旋btn完全对齐*/
如果(aoY<23.89){
log('只需将整个HTML代码放在'body'标记中:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Our Page</title>
<link rel="stylesheet" href="css.css">
</head>
<body>
<!--Put you html code here-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="js.js"></script>
</body>
</html>
我们的网页
在主脚本之前包含任何JavaScript(它是js.js
,并且在这里被排除)。以及“head”标签中的CSS文件。如果没有任何代码,我们如何猜测您可能做错了什么?js.js…惊人的名称,非常描述您的问题是毫无根据的。您尝试了什么,代码在哪里?我知道我在不添加代码但现在添加代码时犯了一个大错误。您添加了代码,但您尝试的是什么要实现吗?这让wheen出现了!现在我只需要让它旋转!确保所有index.html;css.css;js.js文件都在相同的文件夹中是的,仍然是相同的结果。现在我在回答中添加了juery cdn。我想它会工作的。你看到了吗。js.js脚本上面的lscript
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Our Page</title>
<link rel="stylesheet" href="css.css">
</head>
<body>
<!--Put you html code here-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="js.js"></script>
</body>
</html>