Skip to main content

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.

Filter by
Sorted by
Tagged with
1858 votes
33 answers
1.1m views

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's user avatar
  • 34.6k
388 votes
12 answers
240k views

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 │   ├...
zachwill's user avatar
  • 4,593
257 votes
5 answers
366k views

What is syntax for selector in CSS for next element?

If I have a header tag <h1 class="hc-reform">title</h1> h1.hc-reform{ float:left; font-size:30px; color:#0e73bb; font-weight:bold; margin:10px 0px; } and after that I ...
tony noriega's user avatar
  • 7,633
149 votes
18 answers
254k views

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, <div id="outer"> <div id="inner1"></div> ...
codingbear's user avatar
  • 14.9k
110 votes
5 answers
304k views

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): <div class="box"> <div class="something1"></div> &...
Tom's user avatar
  • 30.5k
109 votes
3 answers
361k views

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. <table> <tbody> &...
add-semi-colons's user avatar
68 votes
6 answers
430k views

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 ...
mridul's user avatar
  • 2,046
36 votes
6 answers
56k views

How to select only one sibling with jQuery?

I have this code: <ul> <li class="foo">foo text</li> <li class="foo2">foo2 text</li> <!-- more li here --> <li class="bar">bar text</li> <...
Benjamin Crouzier's user avatar
31 votes
3 answers
31k views

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 (...
The Pied Pipes's user avatar
29 votes
2 answers
37k views

Insert sibling node in JS

So I have a div with some pre tags in it, like so: <div id="editor" > <pre contentEditable="true">1</pre> <pre contentEditable="true">2</pre> <pre ...
Chris's user avatar
  • 12.1k
28 votes
1 answer
30k views

How to get all direct children of a BeautifulSoup Tag? [closed]

How to retrieve (not recursively) all children using BeautifulSoup (bs4) ? <div class='body'><span>A</span><span><span>B</span></span><span>C</span&...
dbrrt's user avatar
  • 2,429
28 votes
1 answer
14k views

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 ...
QMaster's user avatar
  • 3,867
22 votes
6 answers
44k views

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: <tr> <td>3</td> <...
Mike's user avatar
  • 5,818
20 votes
4 answers
21k views

this.nextSibling not working

I expect the following code to alert "out" <input type=text onfocus="alert(this.nextSibling.id)" /> <output id="out">this is output</output> But it alerts undefined WHY?
moroccan_dev's user avatar
20 votes
5 answers
41k views

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). ...
user avatar
19 votes
4 answers
13k views

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 ...
Gary's user avatar
  • 13.8k
17 votes
3 answers
17k views

JQuery - find first sibling matches selector

How can i get the first (next) element in the list that matches the selector ? Example: <table> <tr class="test"><td>not this one</td></tr> <tr><td><...
yossi's user avatar
  • 3,148
16 votes
2 answers
8k views

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 ...
sweepy_'s user avatar
  • 1,333
15 votes
4 answers
47k views

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 ...
DisgruntledGoat's user avatar
15 votes
2 answers
31k views

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 ...
Edu's user avatar
  • 2,533
15 votes
2 answers
44k views

CSS selector if exist adjacent sibling [duplicate]

I have the following (simplified) HTML structure <td> <DIV class="t-numerictextbox"> <DIV class="t-formatted-value">$0.00</DIV> <INPUT id="...
Raymond 's user avatar
14 votes
4 answers
13k views

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 ...
Howdy_McGee's user avatar
  • 10.6k
14 votes
2 answers
8k views

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 ...
golem's user avatar
  • 1,890
14 votes
2 answers
12k views

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 ...
stolsvik's user avatar
  • 5,301
13 votes
2 answers
27k views

Find next siblings until a certain one using beautifulsoup

The webpage is something like this: <h2>section1</h2> <p>article</p> <p>article</p> <p>article</p> <h2>section2</h2> <p>article</...
user1550725's user avatar
12 votes
7 answers
19k views

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 <div> elements on the same level: <div></div> <div></div> &...
Francisc's user avatar
  • 79.4k
12 votes
3 answers
30k views

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

Please take a look at the snippet below: <div> <div></div> <div><!-- my target node --> <div><!-- not my target node --> <img /...
P5music's user avatar
  • 3,297
11 votes
3 answers
8k views

Select last child when odd, 2 last childs when even

I'm in a situation where the number of elements shown is variable, and I need a strange solution that I'm not able to achieve, I even doubt if it's achievable only with CSS. I need to select the last ...
agapitocandemor's user avatar
11 votes
4 answers
31k views

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 ...
eklassen's user avatar
  • 175
11 votes
2 answers
4k views

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 │   └── ...
snazzybouche's user avatar
  • 2,385
9 votes
2 answers
5k views

Change style of all other elements when one element is hovered

Let's say I have a bunch of divs at the same DOM level. When I hover over one, I want all the others to change style (ie. reduce opacity or change background), while the one that is hovered stay the ...
Bobe's user avatar
  • 2,040
9 votes
3 answers
40k views

SQL Server Equivalent of Oracle 'CONNECT BY PRIOR', and 'ORDER SIBLINGS BY'

I've got this Oracle code structure I'm trying to convert to SQL Server 2008 (Note: I have used generic names, enclosed column names and table names within square brackets '[]', and done some ...
user1058946's user avatar
9 votes
3 answers
18k views

XPath select all text content for a <div> except for a specific tag <h5>

I searched and tried several solutions for this problem but none of them worked: I have this HTML <div class="detalhes_colunadados"> <div class="detalhescolunadados_blocos"> <...
bslima's user avatar
  • 1,135
9 votes
1 answer
2k views

jquery removeClass only if all checkboxes of the same set (with same class?) are unchecked

The problem When a checkbox is unchecked, if other checkboxes of the same set (with same class?) are checked, the class shouldn't be removed. Please notice there are several sets of checkboxes. (...
Defeat9274's user avatar
8 votes
1 answer
13k views

How can I show child element above parent element AND siblings of the parent element?

My question is related to this question: Show child element above parent element using CSS The response for that question, to set overflow: visible, works for only one parent of one child. However, ...
rsanchez1's user avatar
8 votes
2 answers
9k views

beautifulsoup: find the n-th element's sibling

I have a complex html DOM tree of the following nature: <table> ... <tr> <td> ... </td> <td> <table> ...
deostroll's user avatar
  • 11.8k
8 votes
4 answers
5k views

mousedown. propagation on siblings event.targets

I have 2 sibling-nodes with 'position absolute' which both handle mousedown event. How can I trigger the handler of 'div 1' when I am clicking on the transparent area of the 'div 2' (on the pic.)
AlaskaKid's user avatar
  • 197
7 votes
1 answer
9k views

Efficiently Detect When Sibling Elements Overlap

Example: <div id="big">&nbsp;</div> <div class="small">&nbsp;</div> <div class="small">&nbsp;</div> <div class="small">&nbsp;</div> <...
Karthik's user avatar
  • 317
7 votes
4 answers
313 views

Prevent equality comparison of sibling structs

I have a number of structs that are derived from the same base for the purpose of code reuse, but I do not want any form of polymorphism. struct B { int field; void doStuff() {} bool ...
Bernard's user avatar
  • 5,377
7 votes
5 answers
17k views

jquery siblings how to remove class?

I have the following jQuery: <script type="text/javascript"> $('.showFood').on('click', function () { $(this).addClass('selected').siblings().removeClass('selected'); $('.targetFood')....
user avatar
7 votes
2 answers
2k views

What would be a use case for dynamic_cast of siblings?

I'm reading Scott Meyers' More Effective C++ now. Edifying! Item 2 mentions that dynamic_cast can be used not only for downcasts but also for sibling casts. Could please anyone provide a (reasonably) ...
sigil's user avatar
  • 825
7 votes
1 answer
22k views

How to implement search bar button and result components in react

I have already seen other answers which are alike, but since I am a beginner, I tried implementing them and I got so confused that nothing worked for me. Here is the problem: I have a search bar (...
HomeMade's user avatar
  • 572
7 votes
1 answer
55k views

PowerShell to get attribute values from XML with multiple attributes

The following XML file is one Object node of the output from the command Get-ClusterGroup run from a 2008 R2 Failover Cluster with PowerShell 2: <?xml version="1.0"?> <Objects> <...
user888818's user avatar
6 votes
4 answers
5k views

How to cycle through siblings using jQuery?

I have the folowing code: html: <div class="container"> <div class="selected">A</div> <div>B</div> <div>C</div> <div>D</div> <...
Benjamin Crouzier's user avatar
6 votes
2 answers
5k views

Jquery Next/NextAll/NextUntil with count limit

Its really annoying me that I don't know the answer to this, I thought it would be simple. I want to get the next and previous elements from a selected element to a limit (say 2). Here is an example: ...
Mike Oram's user avatar
  • 765
6 votes
5 answers
2k views

How to detect strictly adjacent siblings

Consider the following HTML where IDs #p1, #p2 and #p3 are siblings (see fiddle): <div id="container"> <span id="p1">Paragraph 1</span> <span id="p2">Paragraph 2</...
Fabricio's user avatar
  • 839
5 votes
5 answers
28k views

is not a sibling in the same RelativeLayout

Hello I am starting with Android developing. I am just modifying with ECLIPSE an open source example. I have only modified strings.xml and some .png files. In the Android simulator it works perfect ...
javier_pelaez's user avatar
5 votes
3 answers
13k views

XSLT merging/concatenating values of siblings nodes of same name into single node

Input xml <catalog> <product id="1"> <name>abc</name> <category>aaa</category> <category>bbb</category> <...
user1677271's user avatar
5 votes
3 answers
13k views

jquery. how to get each siblings height?

I think this is very easy question for someone who is more experienced in Jquery. for example we have simple html page with a few divs, and 3 of them have the same css class 'sidebar' Each of this '...
Akhmed's user avatar
  • 1,161
5 votes
5 answers
17k views

jquery count siblings does not return correct result?

I want to count the sibling by classes, html, <div class="item-sibling">1</div> <div class="item-holder"><div class="item-sibling">2</div></div> <div class="...
Run's user avatar
  • 56.5k

1
2 3 4 5
15