jquery - Select all elements after a certain element

后端 未结 4 1010
臣服心动
臣服心动 2020-11-30 09:56

I have a list similar to below and would like to only select all of the elements after the #everything_after element.

相关标签:
4条回答
  • 2020-11-30 10:13

    selects all the elements

    $('#element *').attr('selected','selected');
    
    0 讨论(0)
  • 2020-11-30 10:22

    You can use nextAll to get the following divs.

    Try:

    $("#everything_after").nextAll();
    
    0 讨论(0)
  • 2020-11-30 10:28

    See: CSS3 General Siblings Selector

    http://reference.sitepoint.com/css/generalsiblingselector

    $("#everything_after ~ div")...
    
    0 讨论(0)
  • 2020-11-30 10:28

    CASE-1: when the id="" or the class="" selector is known:

    $("#everything_after").nextAll();
    //selects any of the next sibling elements, like <div>, <p>, <i>... etc tags.
    
    //--or--
    $("#everything_after").nextAll("div");
    //selects only the next sibling <div> tags;
    

    CASE-2: when the index of the item is known:

    $("#container > div:nth-child(6)").nextAll();
    //--or--
    $("#container > div:eq(5)").nextAll();
    
    0 讨论(0)
提交回复
热议问题