Blogger Information
Blog 18
fans 0
comment 0
visits 11572
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Javascript中循环和函数的学习***五期线上班
风行的博客
Original
503 people have browsed it

1笔记

a循环

for、 swictch(配合case使用,以及break和continue)、while以及do while区别联系,有do先执行,里边一点要有条件,不然就死循环了;

b函数

函数的申明,调用,传参等;感觉和php基本相同;

2案例

实例

a九九乘法表;

<script type="text/javascript">
	
 // 九九乘法表
	
	for (var i=1; i<10; i++) {
		for (var j=1; j<= i; j++) {
			var space="   ";
			if(i*j<10){
				space += "  ";
			}
				document.write(i+'*'+j+'='+i*j+space);
		    }
	document.write('<br>');
}
</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例

b输出三角形

实例

<!DOCTYPE html>
<html>
<head>
 <title>javascript学习</title>
 <meta charset="utf-8">
 </head>
<body style="text-align:center;">
       

<script type="text/javascript"> 


var t=prompt("请输入行数,要整数才行!","");

function triangle(t) {
 if(t>1){
  for(var r=1;r<=t;r++){
   for(var c=0;c<r;c++){
   document.write("*  ");
    }
      document.write("<br/>");
        }
    }
    else{
         document.write("你给我输出一个看看,反正我是搞不来!")
    }
}
triangle(t);

</script>

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

3心得体会

a php和js有很多共同的地方,可以更好的学习和理解,完美融合;

b js结合html以及css,实现效果事半功倍; 

 

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post