Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>
When writing a JavaScript demo today, I defined a variable. The specific code is as follows:
window.onload = function(){
var panel = document.getElementById(‘panel’);
var right = document.createElement(‘div’);
var bottom = document.createElement(‘div’);
var rg-bom = document.createElement(‘div’);
right.className = ‘right’;
bottom.className = ‘bottom’;
rg-bom.className = ‘rg-bom’;
panel.appendChild(right);
panel.appendChild(bottom);
panel.appendChild(rb-bom);
};
When running, it can’t pass, and prompt in firebug: syntax error: missing; Baidu has no clue about this mistake. It’s all loose. After checking several errors, I didn’t find them. I feel that my code is very correct. After finding the positioning line and changing the RG BOM variable to RG, there is no such error. The original problem is here
It seems that when you define variables in JavaScript, you can’t define them with – lines. Then I changed – lines to ﹣ lines, That’s RG_ BOM, the result is also compiled and passed, which shows that there is a problem with the definition of variables
At this time, I thought of a knowledge point, that is, the problem of identifier in JavaScript, that is, only numbers, letters, $, and underscores, so it is. It seems that my foundation is still too weak. Take this to record the error. In fact, this error is usually caused by a basic grammar problem. If you check it carefully, OK
will happen
Similar Posts:
- [Solved] WebGL Error: uncaught referenceerror unitymodule is not defined
- [Solved] DOM adds elements to HTML Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of typ…
- [Solved] DOM Add Element to HTML Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- [PHP Error]Only variables should be passed by reference
- [Solved] Jquery each error: Uncaught TypeError: Cannot use ‘in’ operator to search for
- [Solved] Lexical declaration cannot appear in a single-statement context
- [Solved] Chrome Browser uploads files for a long time interrupts and reports an error: net :: ERR_NETWORK_IO_SUSPENDED
- C++ error: cannot bind non-const lvalue reference of type ‘myString&’ to an rvalue of type ‘m…
- Syntax error reported by JavaScript function: expected expression, got ‘;’
- Always report uncaught error:[$ injector:modulerr ]Solutions to errors