Skip to content

Collection intersect

maxkfranz edited this page May 11, 2012 · 1 revision

eles.intersect()

Get the intersection of two collections.

eles.intersect( collection )

Gets the elements that are in both eles and in collection
collection : The collection to intersect with

eles.intersect( selector )

Gets the elements that are both in eles and in the collection built by querying the graph with the specified selector (essentially, filters eles with the specified selector) selector : The selector to make the second collection from

Details

If you are familiar with set theory, you will appreciate the value of this function. It allows you to get the set intersection of two collections, rather than you having to duplicate the two loop logic yourself every time you want to get what elements are in both collections.

Examples

var col1 = cy.$("[weight > 50]");
var col2 = cy.$("[weight < 55].foo");
var intersection = col1.intersect( col2 );

Clone this wiki locally