Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Term Entry] JavaScript DOM Manipulation: .querySelectorAll() #6296

Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b7d0b97
Creating new entry for querySelectorAll() method
DimitrovErik Mar 6, 2025
593b516
Creating new entry for querySelectorAll() method
DimitrovErik Mar 6, 2025
346ee8e
Update queryselectorall.md
DimitrovErik Mar 6, 2025
6ce327f
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
9549ccc
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
bafa054
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
39c08cc
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
b9ff516
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
0bfbefd
Adding explanation for 'selectors' parameter in queryselectorall.md
DimitrovErik Mar 7, 2025
772114d
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
cd258b8
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
ce891be
Update content/javascript/concepts/dom-manipulation/terms/queryselect…
DimitrovErik Mar 7, 2025
755f2a7
Deleting the Codebyte Example in queryselectorall.md
DimitrovErik Mar 7, 2025
9f43a77
minor fixes
mamtawardhani Mar 8, 2025
185da65
Fixing format:verify
DimitrovErik Mar 8, 2025
e8e79dc
Merge branch 'main' into javascript-dom-method-querySelectorAll
DimitrovErik Mar 9, 2025
a487511
Merge branch 'main' into javascript-dom-method-querySelectorAll
Sriparno08 Mar 12, 2025
8c84def
Minor changes
Sriparno08 Mar 12, 2025
46c6239
Rename queryselectorall.md to querySelectorAll.md
Sriparno08 Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
Title: '.querySelectorAll()'
Description: 'Returns a static (non-live) NodeList of all elements in the document that match the given CSS selectors.'
Subjects:
- 'Code Foundations'
- 'Web Development'
Tags:
- 'Methods'
- 'Node'
- 'Selectors'
CatalogContent:
- 'introduction-to-javascript'
- 'paths/front-end-engineer-career-path'
---

In JavaScript, the **`.querySelectorAll()`** method under the `document` object returns a static (not live) `NodeList` of all elements that match the given group of [selectors](https://www.codecademy.com/resources/docs/css/selectors).

## Syntax

```pseudo
document.querySelectorAll(selectors);
```

- `selectors`: Represents a string containing one or more CSS selectors used to match elements in the document. It follows the same rules as CSS selectors and can include:
- Type selectors (`div`, `p`, `span`)
- Class selectors (`.class-name`)
- ID selectors (`#id-name`)
- Attribute selectors (`[type="text"]`, `[disabled]`)
- Combinations (`div p`, `.container > p`, `ul > li:first-child`)

## Examples

### Example 1

In this example, a `NodeList` of all `<p>` elements in the document is obtained:

```js
const matches = document.querySelectorAll('p');
```

### Example 2

The following example returns a list of all `<div>` elements in the document with a class of either `note` or `alert`:

```js
const matches = document.querySelectorAll('div.note, div.alert');
```

### Example 3

In this example, a list of `<p>` elements is obtained, whose immediate parent is a `<div>` with the class `highlighted`, and which are inside a container with the ID `test`:

```js
const container = document.querySelector('#test');
const matches = container.querySelectorAll('div.highlighted > p');
```