Home  >  Article  >  Web Front-end  >  JavaScript agrees to wait for code implementation experience_javascript skills

JavaScript agrees to wait for code implementation experience_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:12:321012browse

The correct source program is as follows:

Copy code The code is as follows:

;
And if it is placed outside the function abc(), the program will not be able to implement the function.
The reason is as follows: The browser parses the Html page from top to bottom. When parsing btnReg = document.getElementById("btnReg"), the button with the id btnReg has not been parsed, so the global variable btnReg The value is defined,

and because it is only executed once, the program cannot realize the function, and the correct source program is retrieved every second, and the value can be retrieved after the button button is parsed. The program can realize the function.
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