PrototypeSelector object learning _ prototype

Source: Internet
Author: User
This object does not exist in the help document, but it is indeed the core class of the entire DOM operation. The tool function $ is actually a method to call this class. The Code is as follows:


Function $ (){
Return Selector. findChildElements (document, $ A (arguments ));
}


This class can be divided into three parts: The first part is to determine the DOM operation method used based on different browsers. Here, the Operation IE is to use the common getElementBy * series methods; FF is document. evaluate; Opera and Safari are selectorsAPI. The second part is the basic functions provided externally, such as findElements and match. Many methods in the Element object are called directly. The third part is some DOM matching criteria such as XPath. For example, what strings represent first-child queries and what strings represent nth-child queries.

Because there are many methods in this object, I will not provide all the source code. In fact, I only understand the code of some methods. Here we use a simple example based on different browsers to go through the DOM selection process. In this process, provide the required source code and describe it.

An example is as follows:

The Code is as follows:













Related Article

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.