The process of traversing the Document Object Model (DOM) tree and finding nodes based on certain criterion.
Questions tagged [dom-traversal]
253 questions
164
votes
10 answers
What do querySelectorAll and getElementsBy* methods return?
Do getElementsByClassName (and similar functions like getElementsByTagName and querySelectorAll) work the same as getElementById or do they return an array of elements?
The reason I ask is because I am trying to change the style of all elements…
![](../../users/profiles/1402121.webp)
dmo
- 4,048
- 3
- 22
- 25
69
votes
4 answers
Jquery find nearest matching element
I have a series of rows with columns and I want to select the value of an input field that is in a previous column to the input field (price input) that I am calling a function on when a key is released.
I have tried:
quantity =…
![](../../users/profiles/1320129.webp)
imperium2335
- 20,168
- 36
- 103
- 181
68
votes
6 answers
How to select a single child element using jQuery?
Using jQuery how do I select a single child element? I've looked at the Traversing API and know I can select all the immediate children img elements like this:
$(this).children('img');
And to select the first child img element I could use a…
![](../../users/profiles/59180.webp)
Jonathon Watney
- 15,080
- 8
- 34
- 40
34
votes
1 answer
Is there a way to combine $(this) with :nth-child?
I'm in the middle of an .each iteration and wanted to call out the 2nd or 3rd child for the each..but cant make it work.
alert($(this + ' :nth-child(2)').attr('id'));
My only option that I can think of is something terrible goofy like this:
…
![](../../users/profiles/339463.webp)
Todd Vance
- 4,331
- 7
- 40
- 65
24
votes
10 answers
jQuery append and remove dynamic table row
I can add many rows for a table,
but I can't remove many rows.
I only can remove 1 row per sequential add.