# 1.2.7.1.深入瞭解原始碼：jQeury（一）

* 使語法更容易打出來
* 跨瀏覽器
* 操作DOM

```
<html>
    <head>

    </head>
    <body>
        <div id="main" class="container">
            <h1>People</h1>
            <ul class="people">
                <li>John Doe</li>
                <li>Jane Doe</li>
                <li>Jim Doe</li>
            </ul>
        </div>
        <script src="jquery-1.11.2.js"></script>
        <script src="app.js"></script>
    </body>
</html>
```

* 選擇器

  ```
    //取得class是people的ul中的li
    var q = $("ul.people li")
    //印出jQuery.fn.init[3]
    console.log(q)
  ```
* [jQuery 1.12.4 原始碼](https://code.jquery.com/jquery-1.12.4.js)
  * jQuery函數不是函數建構子, 所以不用[new](https://jenhsuan.gitbooks.io/javascript-node-js/content/chapter1/125han-shu-jian-gou-zi-3001-300c-new-300d-yu-javascript-de-li-shi/1251han-shu-jian-gou-zi-3001-300c-new-300d-yu-javascript-de-li-shi.html)運算子, 而藉由呼叫函數建構子回傳物件
  * 小訣竅: 利用函數呼叫函數建構子, 可以不用使用new運算子
  * jQuery.fn是jQuery.prototype的別名

    ```
    jQuery = function( selector, context ) {

        // The jQuery object is actually just the init constructor 'enhanced'
        // Need init if jQuery is called (just allow error to be thrown if not included)
        return new jQuery.fn.init( selector, context );
    },
    jQuery.fn = jQuery.prototype = {

    // The current version of jQuery being used
    jquery: version,

    constructor: jQuery,

    // Start with an empty selector
    selector: "",

    // The default length of a jQuery object is 0
    length: 0,
    ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jen-hsuan-hsieh.gitbook.io/javascript-node-js/chapter1/12javascript-quan-gong-lve-ff1a-ke-fu-js-de-qi-guai-bu-fen/127jian-yan-zhi-ming-de-kuang-jia-yu-zi-yuan-ku/1271shen-ru-liao-jie-yuan-shi-ma-ff1a-jqeury-ff08-yi-ff09.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
