We have a thorough study of value values in input, see a blog today, it is very magical and then study the value of the value in input what exactly corresponds to what values
1, the value of input, this is the development of everyone in the entry encountered a problem
<type= "button" value= "kester"= "alert (value)" >
In this case, the pop-up test pops up as "kester"
2, but in a look at a situation
< Script > var value = 123 ; </ Script > < type= "button"= "alert (value)">
In the mind, in this case value can not find, is not along the scope to find the previous layer of document, should pop up "123", the result is wrong, but the bounce is a null value
3. Is value really not found? The answer, however, is Negative.
Under Debugging tools, The properties of this view are shown with a record: value: "", which confirms that value is null, and the code
<type= "button"= "console.log (this)">
4, so, in input, value is always there, there is no found case, assigned value is the value is assigned value, no assignment value is empty, this everyone should be clear
5. To cite an example
< Script > var Val = 123 ; </ Script > < type= "button"= "console.log (val)">
The disguise brother of value is Val. Val now found on the input object, not found, along the scope of the Document object found, found popup 123
6, whether val=123 is written in front of the back, are accessible, because this is a click event, when the start of this click event, the page has been parsed JS
<type= "button"= "console.log (val)">< script>var val=123; </ Script >
7. Is that so? But in fact, put the statement in the back is not reliable, if there are other <script> code, due to network reasons can not access, because of the blocking effect of <script>, will block the following code, will Error.
<inputtype= "button"onclick= "alert (val)"><Scriptsrc= "http://www.qq.com/test.js"></Script><Script>varVal=123;</Script>
JavaScript Little Knowledge Point