jQuery: find() children until a certain threshold element is encountered

前端 未结 4 1297
不思量自难忘°
不思量自难忘° 2021-02-19 17:59

I have a nested table structure like

   
4条回答
  •  孤独总比滥情好
    2021-02-19 18:43

    eh, i have a better idea..

    var badTable = "table.bad"; //the one you want to avoid
    var $goodInputs = $("#first").find('input').filter(function() {
        return $(this).closest(badTable).length == 0;
    });
    

    this may or may not be fast enough for you. it depends on your DOM which you do not want to talk about ;)

    if its slow, just write the code for your algorithm by hand. There isnt a selector shortcut.

提交回复
热议问题