Jquery1.3.2 source code learning-6 size and get Functions

Source: Internet
Author: User

96 // Start with an empty Selector

97 selector:"",

98

99// The current version of jquery being used

100 jquery:"1.3.2",

101

102// The number of elements contained in the matched element set

103 size:Function(){

104Return This. Length;

105 },

106

107// Get the nth element in the matched element set or

108// Get the whole matched element set as a clean Array

109 get:Function(Num ){

110ReturnNum === undefined?

111

112// Return a 'clean' Array

113 array. Prototype. Slice. Call (This):

114

115// Return just the object

116This[Num];

117 },

 

Slave97Line starts538Line, definedJqueryThe methods and attributes shared by the object.

 

97The row defines an attribute on the object.SelectorIndicates the selector currently in use.

110The row defines an attribute on the object. Jquery, Indicating the currentJqueryVersion

103The row definesJqueryObjectSizeMethod, becauseJqueryThe object is an array-like object.LengthAttribute, that is, the number of objects in the query results.

 

109To117Line, definedGetMethod to return the query object of the specified subobject.

Where110The row is used to determine whether the subscript parameter is passed. If the subscript parameter is passed, the parameterNumNot equal Undefined, Note that===Used to determine whether it is completely equal.

If a parameter is passed116Row through attribute Indexer[]To obtain the specified object.

If no parameter is passed, use113Line Processing.

113 The row first passes Array. Prototype Find Array Because the array method is provided by this prototype object. Then, call Slice Method. Call Used to take the first parameter as the method This Parameter input, that is, to obtain the current query result object, the array Slice Two parameters can be passed. The first parameter indicates the start subscript, and the second parameter indicates the end subscript. If neither of the two parameters is provided, the start subscript is 0, End subscript is Length . Slice Returns the subscript from start to end. -1 And encapsulate the results into a new real array object.

 

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.