The interesting "(" and "[" in Javascript

Source: Internet
Author: User

I remember a bet with my colleagues a few years ago, <input id = "txtname" type = "text" size = "2" value = "test" name = "txtname"> the object uses document. all ["txtname"]. value and document. all ("txtname "). which of the two values is correct? In fact, both operations can obtain the value, so no one will lose.

 

But today we have encountered the same problem. I don't know whether the problem is caused by the IE version. The two returned values are different. The former is normal, and the latter cannot get the value.

 

The former obtains a text box object, while the latter obtains the object but does not know what the object is.

 

The specific difference is not clear yet. Find the reason and try again ......

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.