forked from cytoscape/cytoscape.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Collection filter
maxkfranz edited this page Mar 8, 2012
·
4 revisions
Get elements that match a specified filter function or selector.
Gets the elements in the collection matching the specified selector
selector : Elements matching this selector will be in the returned collection
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 ofelementin the collection
element: The current element in the iteration
A new collection containing the matching elements is returned by this function.
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();