Questions tagged [siblings]

The term "sibling" refers to a kind of relationship between two items in a tree structure. Two items have the sibling relationship if they both have the same parent.

The term "sibling" refers to a kind of relationship between two items in a tree structure. Two items have the sibling relationship if they both have the same parent. The sibling relationship is most commonly used in reference to elements in document model objects (DOM's) such as XML documents or HTML documents.

In XPath, a language used to address and locate parts of an XML document, the sibling relationship is directly supported by two axis:

  • following-sibling axis refers to all the following siblings of the context node, and
  • preceding-sibling axis refers to all the preceding siblings of the context node

In addition, two more XPath axis support the sibling concept indirectly:

  • the following axis and
  • the preceding axis
732 questions
18
votes
4 answers

Select an element and its siblings

Toggling an element and its siblings can be accomplished as: $(this).toggle(); $(this).prev().toggle(); Combining them doesn't work: $(this,$(this).prev()).toggle(); How can both be selected at the same time?
Gary
  • 13,303
  • 18
  • 49
  • 71
17
votes
3 answers

JQuery - find first sibling matches selector

How can i get the first (next) element in the list that matches the selector ? Example:
not this one
click
not this one
this…
yossi
  • 3,090
  • 7
  • 45
  • 65
16
votes
2 answers

React Native Pass data between sibling views

I'm developing a simple todo-list app using React Native, my issue is the following: I have a NavigatorIOS at the root of my project, with a component containing a ListView as initial route, and a navigation bar button that leads to a task creation…
sweepy_
  • 1,333
  • 1
  • 9
  • 28
15
votes
4 answers

Hide an element's next sibling with Javascript

I have an element grabbed from document.getElementById('the_id'). How can I get its next sibling and hide it? I tried this but it didn't work: elem.nextSibling.style.display = 'none'; Firebug error was elem.nextSibling.style is undefined.
DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
15
votes
2 answers

CSS selector if exist adjacent sibling

I have the following (simplified) HTML structure
$0.00
Raymond
  • 245
  • 1
  • 3
  • 5
15
votes
2 answers

JQuery next() - Getting the next sibling using only classes

I'm trying to create something like a web accordion. Visual example: [TITLE DIV 1] [CONTENT DIV 1] [TITLE DIV 2] [CONTENT DIV 2] [TITLE DIV 3] [CONTENT DIV 3] I want to be able to toggle (jquery function toggle()) a "Content Div" by clicking on the…
Edu
  • 2,354
  • 5
  • 32
  • 36
14
votes
2 answers

What is a sibling class in Python?

Python 2 documentation says that super() function "returns a proxy object that delegates method calls to a parent or sibling class of type." The questions: What is a sibling class in Python? How do you delegate a method call to a sibling class? My…
golem
  • 1,820
  • 1
  • 20
  • 25
14
votes
4 answers

JavaScript equivalent to JQuery .next()

Is there a JavaScript method similar to jQuery .next()? I want to find the next element that has the class of "error" relative to the element. I've tried using .nextSibling as a loop but couldn't figure it out. Didn't know if there was an easier way…
Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186
14
votes
2 answers

Gradle projects depending on artifacts created by sibling projects

I have this Gradle setup with four projects, a parent with three children, where a Java Servlet JSON 'backend' is built into a war-file, and then a static HTML5 'frontend' consuming this is built into a zip. Both these "installs" their artifcats to…
stolsvik
  • 5,253
  • 7
  • 43
  • 52
13
votes
2 answers

Find next siblings until a certain one using beautifulsoup

The webpage is something like this:

section1

article

article

article

section2

article

article

article

How can I find each section with articles within them? That is, after finding h2,…
user1550725
  • 177
  • 1
  • 1
  • 6
12
votes
7 answers

How to implement "prevUntil" in Vanilla JavaScript without libraries?

I need to implement the functionality of jQuery's prevUntil() method in Vanilla JavaScript. I've got several
elements on the same level:
I'm trying to use an onclick…
Francisc
  • 77,430
  • 63
  • 180
  • 276
12
votes
3 answers

How to get the parent node of an element when the parent has siblings?

Please take a look at the snippet below:
As you can see the img-elment has…
P5music
  • 3,197
  • 2
  • 32
  • 81
11
votes
3 answers

Select last child when odd, 2 last childs when even

I'm in a situation where the number of elements showed is variable, and I need a strange solution which I'm not able to achieve, I even doubt if it's achievable only with css. I need to select the last-child if my number of elements is odd, and the…
agapitocandemor
  • 696
  • 11
  • 25
11
votes
4 answers

CSS Sibling Selector w/ Hover

So here's what I'm trying to do: I have two icons side by side, and underneath I have two spans that are hidden. When I mouse-over an icon I want the corresponding span to appear. ------------ HTML Part -----------------
eklassen
  • 175
  • 2
  • 3
  • 8
10
votes
2 answers

How to import from a sibling directory in python3?

I have the following file structure: bot ├── LICENSE.md ├── README.md ├── bot.py # <-- file that is executed from command line ├── plugins │   ├── __init__.py │   ├── debug.py │   └── parsemessages.py ├── helpers │   ├── __init__.py │   ├──…
snazzybouche
  • 2,241
  • 3
  • 21
  • 51
1
2
3
48 49