Skip to content
maxkfranz edited this page Mar 8, 2012 · 4 revisions

eles.filter()

Get elements that match a specified filter function or selector.

eles.filter( selector )

Gets the elements in the collection matching the specified selector

selector : Elements matching this selector will be in the returned collection

eles.filter( function(i, element) )

Gets the elements in the collection for which the specified callback function returns a truthy value

function(i, element) : The filter function which returns true for elements desired to be in the returned collection
i : The index of element in the collection
element : The current element in the iteration

Details

A new collection containing the matching elements is returned by this function.

Examples

cy.elements().filter("[weight > 50]:selected").remove();

// this is the same as the above but with a filter function
cy.elements().filter(function(i, element){
  return element.data("weight") > 50 && element.selected();
}).remove();

Clone this wiki locally