Home > Web Front-end > JS Tutorial > What are javascript annotations?

What are javascript annotations?

(*-*)浩
Release: 2020-09-18 17:14:16
Original
3149 people have browsed it

Javascrip comment characters are divided into single-line comment characters "//" and multi-line comment characters "/**/". Single-line comments start with "//", followed by the comment content, and the syntax is "//comment content"; multi-line comments start with "/*" and end with "*/" ending with the comment content in the middle. The syntax is "/* comment content*/" .

What are javascript annotations?

JavaScript Comments

JavaScript will not execute comments.

We can add comments to explain JavaScript or improve the readability of the code.

Single-line comments start with //.

Example

The following example uses a single-line comment to explain the code:

<!DOCTYPE html>
<html>
<body>
<h1>Welcome to my Homepage</h1>
<p>This is my first paragraph.</p>
<script>
// 输出标题:
document.getElementById("myH1").innerHTML="Welcome to my Homepage";
// 输出段落:
document.getElementById("myP").innerHTML="This is my first paragraph.";
</script>

<p><b>注释:</b>注释不会被执行。</p>

</body>
</html>
Copy after login

JavaScript Multi-line Comment

Multi-line comments start with /* and end with */.

The following example uses multi-line comments to explain the code:

Example

<!DOCTYPE html>
<html>
<body>
<h1>Welcome to my Homepage</h1>
<p>This is my first paragraph.</p>
<script>
/*
下面的这些代码会输出
一个标题和一个段落
并将代表主页的开始
*/
document.getElementById("myH1").innerHTML="Welcome to my Homepage";
document.getElementById("myP").innerHTML="This is my first paragraph.";
</script>

<p><b>注释:</b>注释块不会被执行。</p>

</body>
</html>
Copy after login

The above is the detailed content of What are javascript annotations?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template