Java Programmer's JavaScript learning Note (8--jquery selector)

Source: Internet
Author: User

Plan to complete this note in the following order:

1. Philosophy.
2. Attribute copying and inheritance.
3. This/call/apply.
4. Closure/getter/setter.
5. prototype.
6. Object-oriented simulation.
7. The basic mechanism of jquery.
8. jquery Selector.
9. jquery Tool method.
Jquery-expands at the "class" level.
Jquery-is expanded at the "object" level.
jquery-extension Selector.
JQuery UI.
14. Extend the jquery UI.

This is the 8th of the notes and a chat about the jquery selector.

I've been busy at work recently and haven't updated my notes for a few days.
It's time to calm down and write something today.
Claw machine offline, all by memory, today's notes no code.
Fortunately for jquery selectors, the need to understand their principles is not particularly large, unless you need to implement similar functions, or you need to extend the jquery selector.

Topic 1: Four types of selectors
is actually the four parameter types that pass in the $ () function, respectively:
* DOM object, the recognition method is a NodeType property.
* String: String words in two cases, there may be a CSS selector expression, there are several regular expression matching, or possibly an HTML string.
* Array, this, is not only jquery itself clone,pushstack when used like this?
* function, which is the usual $ (function () {/* My code here */}).

How does the Topic 2:jquery store the objects that are found?
Using this[0],this[1] This way, it can be understood that the internal storage structure is an array.

How is the Topic 3:find method implemented?
Before looking at the source code, I also think this is good magic, the browser should only provide Document.getelementbyid/name/tag and so on. Have always guessed that jquery and browser vendors have a leg, looking back, it is unlikely, not with every browser vendor has a leg.
Look at the source, found that: really is on the basis of document.getelementbyid/name/tag with a reasonable algorithm to achieve.
"Silly" approach is not silly, others are still hesitant to do, people have already made it.
Roughly in two steps, first positioning, narrowing down the range, and then filtering.

All right, let's get here today.

Java Programmer's JavaScript learning Note (8--jquery selector)

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.