如果給出像這樣的結構,我將如何排除#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")
如果給出像這樣的結構,我將如何排除#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")
$(':input:not(#other_section > :input)');
不認爲這會工作!謝謝! – 2012-04-02 21:33:29
這裏是我的解決方案:
$.fn.exclude = (selector)->
excluded_items = @end().find(selector)
@filter ->
!_.include(excluded_items, this)
有很多方法來解釋你的問題。你能提供一個或兩個你想要發生的事情嗎? – Blazemonger 2012-04-02 18:28:57