JavaScript怎样注释掉某行代码

JavaScript怎样注释掉某行代码,第1张

JavaScript怎样注释掉某行代码

JavaScript注释掉某行代码的方法:1、利用“//”可以注释掉单行的代码,语法为“//单行代码”;2、利用“ /*”作为开头,利用“*/”作为结尾可以注释多行代码,语法为“/* 多行代码 */”。

本教程 *** 作环境:windows10系统、javascript1.8.5版、Dell G3电脑。

JavaScript怎样注释掉某行代码

javascript单行注释

单行注释以"//"开头,到改行的末尾结束。下面是javascript单行注释实例:

<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怎样注释掉某行代码的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/699572.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-23
下一篇 2022-04-23

发表评论

登录后才能评论

评论列表(0条)

保存