Converting DOM to image as an array of objects based on jquery

Source: Internet
Author: User
Tags constructor

1, jquery object (this point) is actually a key-value pair of data collection, a common hashtabel. In a collection, a custom key name can be either a letter or an integer, indexed by {name1: "value1", Name2: "value2"}[name2] and {0: "value1", 1: "value2"}[1] There is no difference, The latter data structure has nothing to do with arrays (array), what about "[document]"?

2. The jquery framework, in which the filter DOM object is stored in the properties of the jquery object while the constructor jQuery.fn.init the constructor returns the JQuery object, stores the DOM element data key in the form of 0, 1, 2 ... and defines a length property that is designed to facilitate (compatible) the Jquery.each of manipulating DOM elements. Take a look at the following concise simulation to understand:

Jquery.each = function (object, callback, args) {//object can be an array array:[...] can also be objects object:{0:dom1, 1:dom2, 2:dom3 ... length:3+}
for (var i = 0; i < object.length i + +) {
Callback.call (Object[i], I, ARG)
}
Return object
}

Jquery.each (this, function (I, ARG) {//Here This is the JQuery object, passing through the key names 0, 1, 2 in the Jquery.each ... circular index, It is convenient to get each DOM element (DOM object) to handle the manipulation.
        method ..... .......
       //operations 1 (or bulk operations) DOM elements and returns the JQuery object (this).
}, Arg)

<div id= "Div1" ></div>
<script>
Function A () {
    this[0] = ' Hello ';
    this[1] = ' world ';
    this[2] = document.body;
    This[3] = document.getElementById ("Div1");
    this.length = 4;
    return this;
}
//Here is very casual, the function is all right, take a look at the following several, optional:
A.prototype.splice = function () {};//Generally this is the way to get a null function
A.prototype.splice = Window.moveto; Want to make people dizzy, you can deliberately this way
A.prototype.splice = A;//meaningless, save code
A.prototype.splice = [].splice; //jquery is used for this trick, This is also a closed jquery method, the unknown said.

Var a=new a ();
Console.debug (a);
</script>

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.