前端:Uncaught TypeError: Cannot set property 'value' of null;

(When separate JS and HTML tags) 1. When writing JS code to bind event, there will be found the following error message:

Uncaught TypeError: Cannot set property 'onclick' of null

example:

 

2. there is a line missing from div style "symbol, resulting in lower id when formatting are more of a space, you can not find the id when the object is initialized,

3. sicm.showInfo (here given: the order of execution cause of the problem) 

 

Reason: This is because the browser when obtaining the code returned by the server is in the order of execution, so if the html dom tree has not been fully generated when you execute js, it will not be read into the situation of certain elements appear so js code will not be executed!

solution:

  1. Carefully check the label "" whether security will be late autumn and

  2. Check if the order of the code feasibility of removing unnecessary output directly like

 

Guess you like

Origin www.cnblogs.com/null/p/11200780.html