js入门例题

js入门例题

js.html代码显示方式一(完整显示)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Html welcome you</title>
<script>
alert('hello');
function fn() {
 alert('bbbbbbbbbbbbbbbbbb');
}
</script>
</head>
<body>
<h1>JS welcome you</h1>
<script>
//阶乘
document.write("<h1>阶乘</h1>");
var  fact = 1;
for (i = 1; i < 10; i++) {
 fact = fact * i;
 document.write(i + "i = " + fact + "<br>");
}
document.write("<br>");
document.write("<br>");

//斐波那契数列
document.write("<h1>table of Fibonacci Numbers</h1>");
for (i = 0, j = 1, k = 0, fib = 0; i < 50; i++, fib = j + k, j = k, k = fib) {
 document.write("Fibonacci (" + i + ") = " + fib);
 document.write("<br>");
}
</script>
<button onclick="alert('aaaaaaaaaaaaaaaaaaaaaaaa');">
click here</button><br>
<button onclick="fn()">
click other</button>
</body>
</html>

js.html代码显示方式一(简单显示:省略html,head,body)

<script>
 alert('hello');
 function fn() {
  alert('bbbbbbbbbbbbbbbbbb');
 }
</script>
<h1>JS welcome you</h1>
<script>
 //阶乘
 document.write("<h1>jiecheng</h1>");
 var fact = 1;
 for (i = 1; i < 10; i++) {
  fact = fact * i;
  document.write(i + "i = " + fact + "<br>");
 }
 document.write("<br>");
 document.write("<br>");

 //斐波那契数列
 document.write("<h1>table of Fibonacci Numbers</h1>");
 for (i = 0, j = 1, k = 0, fib = 0; i < 50; i++, fib = j + k, j = k, k = fib) {
  document.write("Fibonacci (" + i + ") = " + fib);
  document.write("<br>");
 }
</script>
<button onclick="alert('aaaaaaaaaaaaaaaaaaaaaaaa');">click here</button>
<br>
<button onclick="fn()">click other</button>



柳德才
13691193654
18942949207
QQ:422157370
[email protected]
湖北-武汉-江夏-庙山

你可能感兴趣的:(js入门例题)