Skip recursion in jQuery.find() for a selector?

后端 未结 8 1061
孤独总比滥情好
孤独总比滥情好 2020-12-18 05:31

TL;DR: How do I get an action like find(), but block traversal (not full stop, just skip) for a certain selector?

ANSWERS: $(Any).fin

8条回答
  •  执念已碎
    2020-12-18 06:18

    If I understand you:

    understanding your needs better and applying the specific classes you need, I think this is the syntax will work:

    var targetsOfTopGroups  = $('.InterfaceGroup .Interface:not(.Interface .Interface):not(.Interface .InterfaceGroup)')
    

    This Fiddle is an attempt to reproduce your scenario. Feel free to play around with it.


    I think I found the problem. You were not including the buttons in your not selector

    I changed the binding to be

            var Controls = $('.InterfaceGroup .Interface :button:not(.Interface .Interface :button):not(.Interface .InterfaceGroup :button)');
    

    Fiddle

提交回复
热议问题