Javascript 基础教程之注释
注释的作用是提高代码的可读性,帮助自己和别人阅读和理解你所编写的JavaScript代码,注释的内容不会在网页中显示。注释可分为单行注释与多行注释两种。
我们为了方便阅读,注释内容一般放到需要解释语句的结尾处或周围。
单行注释://
请看下面的实例:
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>javascript</title>
</head>
<body>
	<script type="text/javascript">
		//document.write("HELLO    ");
		document.write("WORLD    ");        //输出world
		document.write("php中文网    ");
		document.write("php.cn   ");
		document.write("世界你好");
	</script>
</body>
</html>我们只注释了一个输出hello 后面我们还有个注释,写上这句话的意思当我们运行的时候也是不会显示在页面上的,但是这样别人看你的源码就更容易理解了
多行注释:/*注释内容*/
下面我们看一个例子,这样我们就可以吧前面的俩行给注释掉,从而不会执行
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>javascript</title>
</head>
<body>
	<script type="text/javascript">
		/*document.write("HELLO    ");
		document.write("WORLD    ");
		*/
		document.write("php中文网    ");
		document.write("php.cn   ");
		document.write("世界你好");
	</script>
</body>
</html>注:如上述案例,当我们需要注释掉前面2句的时候,也是可以使用快捷键 ctrl+问号键即可 前提是要先选中我们要注释的内容
 
			 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
								 
								 
								 
								

 
  
             
        
据说名字长的人会有很多女朋友
这个不难,理解
8年前 添加回复 0