如果给出这样的结构,我最好如何从#other_section中排除结果?
<form>
<input id=one>
<div id=other_section>
<input id=two>
</div>
</form>
这是一个可能的API:
inputs = @find(":input").exclude("#other_section :input")
答案 0 :(得分:2)
$(':input:not(#other_section > :input)');
答案 1 :(得分:0)
这是我的解决方案:
$.fn.exclude = (selector)->
excluded_items = @end().find(selector)
@filter ->
!_.include(excluded_items, this)