The process of traversing the Document Object Model (DOM) tree and finding nodes based on certain criterion.
Questions tagged [dom-traversal]
262 questions
204
votes
12 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…

dmo
- 5,102
- 3
- 25
- 28
88
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…

Jonathon Watney
- 20,248
- 9
- 38
- 40
74
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 =…

imperium2335
- 23,402
- 38
- 111
- 190
35
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:
…

Todd Vance
- 4,627
- 7
- 46
- 66
26
votes
11 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.