Linked Questions

2 votes
1 answer
4k views

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=&...
talaing's user avatar
  • 61
0 votes
4 answers
1k views

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="...
卓琮偉's user avatar
  • 179
0 votes
2 answers
2k views

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 ...
Ludus H's user avatar
  • 239
0 votes
0 answers
47 views

<div id="div"> <h1 id="1">Index 1</h1> <h1 id="2">Index 2</h1> <h1 id="3">Index 3</h1> </div> // ...
user avatar
23 votes
7 answers
70k views

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">...
Sake's user avatar
  • 665
0 votes
3 answers
3k views

Do you know how I could recover an item deleted with JavaScript in the following way: elem1.parentNode.removeChild(elem1);
Ivan's user avatar
  • 35
0 votes
2 answers
4k views

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 "./...
creativated's user avatar
0 votes
3 answers
4k views

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 ...
jeromej's user avatar
  • 12k
3 votes
2 answers
2k views

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 ...
Michael Moreno's user avatar
-1 votes
2 answers
1k views

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 ...
Leith's user avatar
  • 155
0 votes
2 answers
989 views

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 ...
Woody's user avatar
  • 8,082
0 votes
1 answer
332 views

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 ...
Aashish Loknath Panigrahi's user avatar
2 votes
0 answers
355 views

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 ...
dodov's user avatar
  • 6,004
0 votes
0 answers
290 views

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). ...
dcp3450's user avatar
  • 11.2k
1 vote
3 answers
80 views

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"); ...
user avatar

15 30 50 per page