javascript注释掉某行代码的方法:1、利用“//”可以注释掉单行的代码,语法为“//单行代码”;2、利用“ /*”作为开头,利用“*/”作为结尾可以注释多行代码,语法为“/* 多行代码 */”。
本教程操作环境:windows10系统、javascript1.8.5版、dell g3电脑。
javascript怎样注释掉某行代码
javascript单行注释
单行注释以//开头,到改行的末尾结束。下面是javascript单行注释实例:
<html><head><title>javascript单行注释</title><script language="javascript"><!--// the first alert is belowalert("an alert triggered by javascript!");// here is the second alertalert("a second message appears!");// --></script></head><body></body></html>
javascript多行注释
多行注释以 /* 开始,以 */ 结尾。下面的例子使用多行注释来解释代码:
<html><head><title>javascript多行注释</title><script language="javascript"><!--/*below two alert() methods are used tofire up two message boxes - note how thesecond one fires after the ok button on thefirst has been clicked*/alert("an alert triggered by javascript!");alert("a second message appears!");// --></script></head><body></body></html>
【相关推荐:javascript学习教程】
以上就是javascript怎样注释掉某行代码的详细内容。