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.

Two sections are compared before an error is introduced.CodeTo 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 () ;}< br> // document. getelementbyid ('delnode '). onclick = delnode;
}< br> 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;
}< br>/* function delnode () {
return false;
} */

A person with a fine mind may be able to see it at a glance, but I am not a good player. The difference is that 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 will occur.
comment. What does it mean, there is incomplete content, and the Program is invalid. This is not a complicated task, but it wastes me a long time, write it out and share it with everyone !!!

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.