Home >Web Front-end >JS Tutorial >How to make multi-line comments in javascript
How to make multi-line comments in javascript: first create an HTML sample file; then add a script tag in the head tag; then write javascript code in the script tag; finally use "/*. ..*/" symbols can be used for multi-line comments.
The operating environment of this article: windows7 system, javascript1.8.5&&html5 version, Dell G3 computer.
js single-line and multi-line comment writing format
The role of comments is to improve the readability of the code and help yourself and others read and understand the JavaScript code you write. , the content of the annotation will not be displayed on the web page. Comments can be divided into two types: single-line comments and multi-line comments.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript-注释很重要</title> <script type="text/javascript"> document.write("我是单行注释'//'");//该语句在网页中输出的单行注释内容不展示 document.write("我是多行注释'/*注释内容*/'"); /* 哈哈,我是多行注释 神奇的js把我隐藏了,看不见 记得养成良好的注释习惯 */ </script> <style type="text/css"> div::selection{ background-color: #00FFFF; /* color: #fff; */ } </style> </head> <body> <div>html与css注释还记得如何书写吗</div> <!-- <div>html与css注释还记得如何书写吗</div> --> </body> </html>
Summary: The comment content is generally placed at or around the end of the statement that needs to be explained. For single-line comments, add the symbol "//" before the comment content. At the same time, multi-line comments start with "/*" and end with "* /"End, did you find that the multi-line comments of javascript are the same as the comments of css
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to make multi-line comments in javascript. For more information, please follow other related articles on the PHP Chinese website!