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
Jekyll Site Works Locally But Not on Github Pages
Is There Any Equivalent to Ie Conditional Comment for Chrome and Safari
How to Use CSS in Js for Nested Hover Styles, Material Ui
In CSS Grid Why Is 1Fr+9Fr Not Behaving the Same as 10Fr in Small Screen Sizes
CSS Variable Calculation of Hsl Values
How to Have Brand and Navbar on Separate Lines
Bootstrap - Do We Have to Use Rows and Columns
Foundation 5 Build Isn't Complete
Bootstrap 3 Grid System Does Not Work Correctly Within a 3Rd Party Styled Div (Kendo)
Parent Selector Nested Inside &:Hover
How to Create a Responsive Checkerboard Background in CSS
Can't Get Z-Index to Work for Div Inside of Another Div
Skew One Side Only of an Element
How to Animate Flexbox Inserts & Removes
Bullets Disappear with CSS3 Columns
CSS Transitions Between Absolute and Relative Positioning