Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Commit f05b32d

Browse files
committed
Add namedItem example
1 parent fb48e56 commit f05b32d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ An element must match the selector as well as the type for it to be returned.
2222
- `getAttribute(element, name)`
2323

2424
```js
25-
import {closest, getAttribute, query, querySelectorAll} from '@github/query-selector'
25+
import {closest, getAttribute, namedItem, query, querySelectorAll} from '@github/query-selector'
2626

2727
// Find an element by selector and type, or throw if not found.
2828
const image: HTMLImageElement = query(document, '.avatar', HTMLImageElement)
@@ -40,6 +40,11 @@ for (const input of inputs) {
4040

4141
// Retrieve the attribute's value or throw.
4242
const url: string = getAttribute(image, 'data-url')
43+
44+
45+
// Find the form's `input[name=login]` field or throw if not found.
46+
const form: HTMLFormElement = query(document, 'form', HTMLFormElement)
47+
const input: HTMLInputElement = namedItem(form, 'login')
4348
```
4449

4550
## Motivation

0 commit comments

Comments
 (0)