Select All Elements After Specific Element

Select all elements after specific element

You can use

.divider ~ li {
background-color:green;
}

jquery - Select all elements after a certain element

You can use nextAll to get the following divs.

Try:

$("#everything_after").nextAll();

CSS select all elements of the same type after this element

Try

#login input:focus ~ label  {display:inline-block;}

plus(+) selects the adjacent siblings while ~ looks for the next sibling

Reference for general sibling selector: https://developer.mozilla.org/en/docs/Web/CSS/General_sibling_selectors

Reference for adjacent sibling selector:
https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_selectors

Select all elements with same class after an element

.y after #b

That would be

#b ~ .y

and before the next .x

This is a little tricky. If there may be another .x element and you want to avoid styling .y elements that follow that .x element, you'll most probably need an overriding rule (after the first):

#b ~ .y {
/* Style all .y that follow #b */
}

#b ~ .x ~ .y {
/* Revert styles for .y that follow the next .x after #b */
}

Jsoup: get all elements before a certain element / remove all elements after a certain element

Explanation in comments:

Element petsWrapper = document.selectFirst(".pets");
Elements pets = petsWrapper.select(".pet");
// select middle element
Element middleElement = petsWrapper.selectFirst(".friends-pets");
// remove from "pets" every element that comes after the middle element
pets.removeAll(middleElement.nextElementSiblings());
System.out.println(pets);

Select all elements in a list after class is matched

use sibling selector ~ like this:

.animate-out ~ li {

background: red

}
<ul>

<li>One</li>

<li>Two</li>

<li class="animate-out">Three</li>

<li>Four</li>

<li>Five</li>

</ul>

How to get all elements after selected element

You could just use nextAll() instead:

$('div.current').nextAll().addClass('foo');
.foo { color: #00F; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<div>First</div>

<div>Second</div>

<div class="current">Third</div>

<div>Fourth</div>

<div>Fifth</div>

<div>Sixth</div>

<div>Seventh</div>

How to print all elements after a specific element in a list?

def main():
b = [1, 3, 2, 5, 4, 7, 6]
node = 5
for i in range(-1, -len(b), -1):
if b[i] == node:
for j in b[i+1:]:
print(j)
return 0
for i in b:
print(i)

if __name__ == "__main__":
main()

Select all elements before element with class?

a {

text-decoration: none;

border-left: 1px solid black;

}

a.active, a.active ~ * {

border: none;

}
<div>

<a href>One</a>

<a href>Two</a>

<a href>Three</a>

<a href class="active">Four</a>

<a href>Five</a>

</div>


Related Topics



Leave a reply



Submit