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
1795
votes
33 answers

Is there a "previous sibling" selector?

The plus sign selector (+) is for selecting the next adjacent sibling. Is there an equivalent for the previous sibling?
Jourkey
  • 33,710
  • 23
  • 62
  • 78
369
votes
18 answers

Sibling package imports

I've tried reading through questions about sibling imports and even the package documentation, but I've yet to find an answer. With the following structure: ├── LICENSE.md ├── README.md ├── api │   ├── __init__.py │   ├── api.py │   └──…
zachwill
  • 4,395
  • 3
  • 19
  • 17
248
votes
5 answers

What is syntax for selector in CSS for next element?

If I have a header tag

title

h1.hc-reform{ float:left; font-size:30px; color:#0e73bb; font-weight:bold; margin:10px 0px; } and after that I have a paragraph

stuff here

. How can I ensure using…
tony noriega
  • 7,523
  • 17
  • 53
  • 72
145
votes
17 answers

Is there a way to select sibling nodes?

For some performance reasons, I am trying to find a way to select only sibling nodes of the selected node. For example,
codingbear
  • 14,773
  • 20
  • 48
  • 64
109
votes
5 answers

jQuery: How to get to a particular child of a parent?

To give a simplified example, I've got the following block repeated on the page lots of times (it's dynamically generated):
My link
Tom
  • 30,090
  • 27
  • 90
  • 124
106
votes
3 answers

XPath:: Get following Sibling

I have following HTML Structure: I am trying to build a robust method to extract second color digest element since there will be many of these tag within the DOM. …
add-semi-colons
  • 18,094
  • 55
  • 145
  • 232
63
votes
6 answers

How to display and hide a div with CSS?

In my script there are three divs. I want to display div with class="ab" when I hover on first line and display div with class="abc", when hover on second line. Otherwise I want to display div with class="a" by default. But it never displays the div…
mridul
  • 1,986
  • 9
  • 29
  • 50
36
votes
6 answers

How to select only one sibling with jQuery?

I have this code:
31
votes
3 answers

How do I set state of sibling components easily in React?

I have got the beginnings of a clickable list component that will serve to drive a select element. As you can see from the below, onClick of the ListItem, I'm passing the state of a child element (ListItem in this case) to the parents…
The Pied Pipes
  • 1,425
  • 2
  • 16
  • 29
27
votes
2 answers

Insert sibling node in JS

So I have a div with some pre tags in it, like so:
1
2
3
Now I want to use Javascript to put a new pre node…
Chris
  • 11,819
  • 19
  • 91
  • 145
27
votes
1 answer

Difference between previoussibling and previouselementsibling-javascript

I wonder if I know What is the difference between javascript previousSibling and previousElementSibling. I tried and I didn't find any question or article that compare or describe this. Maybe this is for my little javascript knowledge, but I…
QMaster
  • 3,743
  • 3
  • 43
  • 56
27
votes
1 answer

How to get all direct children of a BeautifulSoup Tag?

How to retrieve (not recursively) all children using BeautifulSoup (bs4) ?
ABC
I want to get blocks like this : block1 : A block2 :…
dbrrt
  • 2,275
  • 4
  • 18
  • 35
22
votes
6 answers

Select first sibling

I'm trying to select the inner value of the first sibling - using jQuery - in an environment where I cannot alter the html markup. I have the following:
3 bob smith bob@example.com
Mike
  • 5,568
  • 11
  • 31
  • 45
20
votes
4 answers

this.nextSibling not working

I expect the following code to alert "out" this is output But it alerts undefined WHY?
moroccan_dev
  • 310
  • 1
  • 2
  • 11
20
votes
5 answers

get nearby sibling in javascript

I have a certain DIV structure with an anchor tag in between somewhere. On click of the link, I need to fetch the value of another span element within the parent div and do something, (say, alert it). The html is like this : ...
user2003007
1
2 3
48 49