jQuery: use filter(), but work with both results

后端 未结 6 1812
孤城傲影
孤城傲影 2021-01-01 23:16

In jQuery, filter() reduces your result to those elements that fulfill a certain condition.

This splits the list in two parts. Working with the \"good

6条回答
  •  长发绾君心
    2021-01-01 23:49

    You might try your hand at writing a jQuery plugin to do this. Check out the code of the filter function, and come up with something that does more precisely what you want. It could be something like:

    $("some selector").processList(predicate, successCallback, failureCallback);
    

    Then you would pass in three callbacks: one that evaluates an object to see if it matches the filter selection (you could also accept a selector string, or the like); one that handles objects that match the selection, and another that handles objects which don't match.

提交回复
热议问题