第29天,在经历了各种灰暗、沮丧、气馁之后,我决定重新振作起来,从头开始学JavaScript,这次是一步步走,扎扎实实的,不投机取巧,如果过了我自己给自己设定的时间,我依然没有学会写脚本的话,我就放弃前端。
今天写了几个小例子,是参照书本上的,是的,我给自己找了一本教材,希望这能帮助到我。我今天才发现,我之前不会写是有原因的,那就是我太眼高手低了,很多最基础的代码和语法,我都能弄错,之前是我太过心急了。老话说的好,心急吃不了热豆腐。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!--第1个例子
<p>房屋单价:8500元/平方米,房屋面积80平方米</p>
<script>
document.write("房屋总价:"+68e4+"元")
</script>-->
<!--第2个例子
<script>
document.write("2017年房贷利率为:"+49e-3)//注意浮点型数据不要加引号
</script>-->
<!--第3个例子
<script>
document.write("<pre>");
document.write("轻松学习\nJavaScript语言");
document.write("<pre/>")//此处注意pre标签的使用
</script>-->
<!--第4个例子
<script>
document.write('<pre>');
document.write('中文名:沙沙');
document.write("\n英文名:Alice");
document.write("\n别名:小苹果");
document.write("<pre/>")
</script>-->
<!--第5个例子
<script>
document.write("E:\\Javascript\\Code\\Try")//注意转义字符\的使用
</script>-->
<!--第6个例子-->
<script>
document.write("<pre>")
document.write("天之道,损有余而补不足\n是故虚胜实,不足胜有余\n")
document.write("\t——《九阴真经》")
document.write("<pre/>")
</script>
</body>
</html>
复制代码
多写,多练。