Home  >  Article  >  Web Front-end  >  Crash example about a semicolon in js_javascript skills

Crash example about a semicolon in js_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:16:20906browse
Copy code The code is as follows:

if ($("span", $("#txtStere") .siblings("div")).text() === "*");
{
if (!IsNum("#txtStere")) {
$("#txtStere"). next().text("The freight template you selected is priced by volume, and the logistics volume cannot be empty and must be a number");
return false;
} else {
$("#txtStere" ).next().text("");
}
}

The above js code will execute the code in curly brackets regardless of whether the result of the if condition is true or false. I After working for more than an hour, I couldn’t figure out what was going on. It crashed and crashed. Finally, by some strange coincidence, I discovered the reason. There was an extra semicolon after the parentheses of the if condition. Is it true? It crashed!
Statement:
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