Remember, any jQuery wrapped set can be used as an array of element references.
1.Determining the size of the wrapped set
Command syntax:size()
Returns the count of elements in the wrapped set
Parameters
none
Returns
The element count
2.Obtaining elements from the wrapped set
Command syntax:get(index)
Obtains one or all of the matched elements in the wrapped set. If no parameter is specified, all elements in the wrapped set are returned in a JavaScript array.
If an index parameter is provided, the indexed element is returned.
Parameters
index (Number) The index of the single element to return. If omitted, the entire set is returned in an array.
Returns
A DOM element or an array of DOM elements.
3.Slicing and dicing the wrapped element set
Command syntax:add(expression)
Adds elements, specified by the expression parameter, to the wrapped set. The expression can be a selector, an HTML fragment, a DOM element, or an array of DOM elements.
Parameters
expression (String|Element|Array) Specifies what is to be added to the matched set.
This parameter can be a jQuery selector , in which case any matched
elements are added to the set. If an HTML fragment, the appropriate
elements are created and added to the set. If a DOM element or an array
of DOM elements, they are added to the set.
Returns
The wrapped set.
eg: $('p').add('<div>Hi there!</div>') //This fragment creates a wrapped set of all <p> elements in the document, and then creates a new <div>, and adds it to the wrapped set
Command syntax:not(expression)
Removes elements from the matched set according to the value of the expression parameter. If the parameter is a jQuery filter selector, any matching elements are removed.
If an element reference is passed, that element is removed from the set.
Parameters
expression (String|Element|Array) A jQuery filter expression, element reference, or array of element references defining what is to be removed from the wrapped set.
Returns
The wrapped set.
eg: $('img[title]').not('[title*=puppy]') //selects all the images with title attribute, then remove the element from the wrapped set which element's title contains "puppy"
Command syntax:filter(expression)
Filters out elements from the wrapped set using a passed selector expression, or a filtering function.
Parameters
expression (String|Function) Specifies a jQuery selector used to remove all elements that do not match from the wrapped set, or a function that makes the
filtering decision. This function is invoked for each element in the set, with the current element set as the function context for that invocation.
Any element that returns an invocation of false is removed from the set.
Returns
The wrapped set.
eg: $('td').filter(function(){return this.innerHTML.match(/^\d+$/)}) //This jQuery expression creates a wrapped set of all <td> elements and then invokes the function passed to the filter() method for each, with the current matched elements as the this value for the invocation. The function uses a regular expression to determine if the element content matches the described pattern
(a sequence of one or more digits), returning false if not. Every element whose filter function invocation returns false is removed from the wrapped set.
Command syntax:slice(begin,end)
Creates and returns a new wrapped set containing a contiguous portion of the matched set.
Parameters
begin (Number) The zero-based position of the first element to be included in the returned slice.
end (Number) The optional zero-based index of the first element not to be included in the returned slice, or one position beyond the last element to be included.
If omitted, the slice extends to the end of the set.
Returns
The newly created wrapped set.
eg: $('*').slice(0,4); //selects all elements on the page and then creates a set containing the first four elements.
4.Getting wrapped sets using relationships
Methods to obtain new wrapped set based on relationships
All of the methods above, with the exception of contents(), accept a parameter containing a string that can be used to filter the results.
5.Even more ways to use a wrapped set
Command syntax:find(selector)
Returns a new wrapped set containing all elements of the original set that match the passed
selector expression.
Parameters
selector (String) A jQuery selector that elements must match to become part of the returned set.
Returns
The newly created wrapped set.
Command syntax:contains(text)
Returns a new wrapped set composed of elements that contain the text string passed as the text parameter
Parameters
text (String) The text that an element must contain in order to be added to the returned set
Returns
The newly created wrapped set
Command syntax:is(selector)
Determines if any element in the wrapped set matches the passed selector expression
Parameters
selector (String) The selector expression to test against the elements of the wrapped set
Returns
true if at least one element matches the passed selector; false if not
6.Managing jQuery chains
Command syntax:end()
Used within a chain of jQuery command to back up the wrapped set to a previously returned set
Parameters
none
Returns
The previous wrapped set
eg: $('img').clone().appendTo('#somewhere').end().addClass('beenCloned'); // clone the original set to the element which id is "somewhere", then add css class to the left of original set
Command syntax:andSelf()
Merges the two previous wrapped sets in a command chain
Parameters
none
Returns
The merged wrapped set
分享到:
相关推荐
He helps you master the basic tools, apply the techniques to manage your resources, and give each area just the right amount of attention so that you can successfully survive managing a test project!
Managing the Test People was written for managers, leads, and people who may soon find themselves in a technical leadership position. It focuses on some of the unique problems in the software quality ...
Infrastructure as Code Managing Servers in the Cloud 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Information Systems Today Managing the Digital World(8th) 英文无水印原版pdf 第8版 pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请...
### FStream: Managing Flash Streams in the File System #### Flash-based Solid State Drives (SSDs) Flash-based SSDs have become a popular alternative to traditional hard disk drives (HDDs) due to ...
The Cloud DBA-Oracle: Managing Oracle Database in the Cloud By Abhinivesh Jain, Niraj Mahajan English | PDF| 2017 | 228 Pages | ISBN : 1484226348 Learn how to define strategies for cloud adoption of...
MANAGING THE DEVELOPMENT OF LARGE SOFTWARE SYSTEMSDr. Winston W. RovceINTRODUCTION l am going to describe my pe,-.~onal views about managing large software developments. I have hadvarious assignments...
In the third edition of the classic Managing Projects with GNU make, readers will learn why this utility continues to hold its top position in project build software, despite many younger competitors...
《管理HIVADIS大流行2006-2055》的压缩包文件,主要涉及的是利用数学建模来研究和预测艾滋病(HIV/AIDS)的传播与发展。在这个领域,数学建模是一种关键的工具,它允许科学家们通过定量分析来理解和预测疾病动态,...
根据提供的文件信息,本文将详细解析“以可靠性为中心的维修(Reliability-Centered Maintenance, RCM)”这一主题,特别是其在水电组织中的应用及管理引入过程。 ### 一、RCM概念及其重要性 ...
### 管理信息系统——管理数字化公司 第9版 #### 知识点概览 **本书作者**:Kenneth C. Laudon 和 Jane P....本书是关于管理信息系统的经典教材之一,旨在帮助读者理解如何在数字时代有效地管理和应用信息系统。...
### 知识点总结 #### 一、书籍基本信息 - **书名**:《管理测试过程:实用工具和技术用于管理硬件和软件测试》 - **作者**:Rex Black - **出版社**:Wiley Publishing, Inc. - **出版年份**:2002年 ...
人力资源,英语人才适用。
Apress - Managing Enterprise Systems with the WSH.chm
In this fully updated second edition of the highly acclaimed Managing Gigabytes, authors Witten, Moffat, and Bell continue to provide unparalleled coverage of state-of-the-art techniques for ...
Lab 02 - Managing LS 2010 Using the LS Management Shell
Infrastructure as Code Managing Servers in the Cloud 高清,无错误,本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书