2012-04-02 66 views
0

如果給出像這樣的結構,我將如何排除#other_section的結果?jQuery排除來自#find結果的選擇器匹配

<form> 
    <input id=one> 
    <div id=other_section> 
    <input id=two> 
    </div> 
</form> 

這裏是一個可能的API:

inputs = @find(":input").exclude("#other_section :input") 
+0

有很多方法來解釋你的問題。你能提供一個或兩個你想要發生的事情嗎? – Blazemonger 2012-04-02 18:28:57

回答

0

這裏是我的解決方案:

$.fn.exclude = (selector)-> 
    excluded_items = @end().find(selector) 
    @filter -> 
    !_.include(excluded_items, this)