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

后端 未结 6 1726
孤城傲影
孤城傲影 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:51

    Interesting question. I see you are leaning toward what I was going to suggest:

    $("some selector").each(function() { 
      if ($(this).is(SOMEFILTER)) { 
        // do something
      } else {
        // do something  
      }
      // continue with things that apply to everything
    }); 
    

提交回复
热议问题