JavaScript Little Knowledge Point

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.