JavaScript注释掉某行代码的方法:1、利用“//”可以注释掉单行的代码,语法为“//单行代码”;2、利用“ /*”作为开头,利用“*/”作为结尾可以注释多行代码,语法为“/* 多行代码 */”。
本教程操作环境:windows10系统、javascript1.8.5版、Dell G3电脑。
JavaScript怎样注释掉某行代码
javascript单行注释
单行注释以"//"开头,到改行的末尾结束。下面是javascript单行注释实例:
立即学习“Java免费学习笔记(深入)”;
<html> <head> <title>javascript单行注释</title> <script language="javascript"> <!-- // The first alert is below alert("An alert triggered by JavaScript!"); // Here is the second alert alert("A second message appears!"); // --> </script> </head> <body> </body> </html>
javascript多行注释
多行注释以 /* 开始,以 */ 结尾。下面的例子使用多行注释来解释代码:
<html> <head> <title>javascript多行注释</title> <script language="javascript"> <!-- /* Below two alert() methods are used to fire up two message boxes - note how the second one fires after the OK button on the first has been clicked */ alert("An alert triggered by JavaScript!"); alert("A second message appears!"); // --> </script> </head> <body> </body> </html>
【相关推荐:javascript学习教程】
以上就是JavaScript怎样注释掉某行代码的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号