Linked Questions
17 questions linked to/from Get child node index
2 votes
1 answer
4k views
How to get index of div in parent div? [duplicate]
is there any way to get index of clicked div in parent div? Here's an example: <div class="parent"> <div id="1" class="child"></div> <div id=&...
0 votes
4 answers
1k views
JavaScript : How to get a name of an element index? [duplicate]
Need to get index number of the element from the array of elements <input type="button" name="test" value="test" onclick="getindex(this)"> <!--index 0--> <input type="button" name="...
0 votes
2 answers
2k views
How to get index of textfield array in the form by using Javascript? [duplicate]
I have a form with dozen of textfield elements. Any change of their values shall execute Javascript function. And until now I know what I shall to do, but I can't detect index of textfield that ...
0 votes
0 answers
47 views
Get the index of an element present inside a div? [duplicate]
<div id="div"> <h1 id="1">Index 1</h1> <h1 id="2">Index 2</h1> <h1 id="3">Index 3</h1> </div> // ...
23 votes
7 answers
70k views
Get an element's nth-child number in pure JavaScript
I am making a function for my site where I set a data attribute which contains the nth-child number of that element. My HTML markup: <html> <body> <section class="hardware">...
0 votes
3 answers
3k views
Recover item deleted with parentNode.removeChild
Do you know how I could recover an item deleted with JavaScript in the following way: elem1.parentNode.removeChild(elem1);
0 votes
2 answers
4k views
how to disable a button if more than once check box is checked in React JS
I have to create a button that activates when a check box is checked and disables when unchecked. I was able to achieve this by the following code. import React from "react"; import "./...
0 votes
3 answers
4k views
How to find the corresponding th to a given td?
Basically the same question as How can I get the corresponding table header (th) from a table cell (td)? but not jQuery specific. From a given <td> is there an easy way to find the ...
3 votes
2 answers
2k views
Select sibling at n distance from index (JavaScript)
I'm looking for a way to traverse DOM element siblings like .nextSibling() allows, but at any given distance instead of the direct next sibling only. For instance if I wanted to move 3 siblings over ...
-1 votes
2 answers
1k views
How to get the index value of the e.target click?
I want to get the index value of the div which has been clicked. I have 6 divs. When I click on them using e.target from the whole document, I want to get the index position of the clicked one from ...
0 votes
2 answers
989 views
HTML5 dropzone attribute relation to dropEffect
The HTML5 spec proposes a dropzone attribute although this has not been implemented as yet in any browsers (it seems like Opera did before they switched to WebKit ?). It's format is e.g. <div ...
0 votes
1 answer
332 views
Why does window.getComputedStyle(element).getPropertyValue("order") doesn't returns order of a flexbox element?
From MDN Web Docs: "window.getComputedStyle() method returns an object containing the values of all CSS properties of an element, after applying active stylesheets and resolving any basic ...
2 votes
0 answers
355 views
Chrome Extension pass node reference from Content Script to DevTools page
I have a simple extension that uses a devtools page to provide debugging functionality. When the browserAction icon is clicked, that page inserts a content script in the current tab. How do I pass a ...
0 votes
0 answers
290 views
Handling event delegation with children
For efficiency I'm tracking the click event against my nav rather than each li. However, each li has a set of span tags inside them. I need to manipulate the clicked li and get it's position (index). ...
1 vote
3 answers
80 views
Trouble getting the index of a child when it is clicked
I'm trying to get the index of a child within a parent element. I followed the answer here, but ended up with an infinite loop. My code so far: var div = document.getElementById("spans"); ...