JavaScript Error: unterminated comment

Source: Internet
Author: User

I have been studying the DOM (Document Object Model) in JavaScript recently. Of course, it cannot be said that it is a study. At most, it is just a study. It is not very difficult to understand the logic Syntax of DOM, it is only possible that some small errors will inevitably occur during encoding. Here, it is difficult to use the word "error.

Before introducing an error, compare two sections of code to see if there is any difference:

1

Window. onload = initAll;

Function initAll (){
Document. getElementById ('form1'). onsubmit = function () {return addNode ();}
// Document. getElementById ('delnode'). onclick = delNode;
}
Function addNode (){
Var inText = document. getElementById ('textarea '). value;
Var newText = document. createTextNode (inText); // create a text node

Var newGraf = document. createElement ('P'); // create an element node
NewGraf. appendChild (newText); // Add text to the element

Var docBody = document. getElementsByTagName ('body') [0];
DocBody. appendChild (newGraf );
Document. getElementById ('textarea '). value = "";

Return false;
}
/* Function delNode (){
Return false;
}

2

Window. onload = initAll;

Function initAll (){
Document. getElementById ('form1'). onsubmit = function () {return addNode ();}
// Document. getElementById ('delnode'). onclick = delNode;
}
Function addNode (){
Var inText = document. getElementById ('textarea '). value;
Var newText = document. createTextNode (inText); // create a text node

Var newGraf = document. createElement ('P'); // create an element node
NewGraf. appendChild (newText); // Add text to the element

Var docBody = document. getElementsByTagName ('body') [0];
DocBody. appendChild (newGraf );
Document. getElementById ('textarea '). value = "";

Return false;
}
/* Function delNode (){
Return false;
}*/

A person with a fine mind may be able to see it at a glance, but I don't belong to this type of excellent player. The difference is that the function delNode, the first is/* function delNode () {return false;}, and the second is/* function delNode () {return false ;}*/, haha, the difference is:/**/whether the annotator is completely written. If it is not completely written, JavaScript Error: unterminated comment may occur. What does it mean that there is incomplete content, the program is invalid. This is not a complicated task, but it wastes me a long time and I will share it with you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.