Skip to content
This repository was archived by the owner on Dec 22, 2025. It is now read-only.

Commit 4505717

Browse files
authored
Update README.md
Signed-off-by: xusd320 <[email protected]>
1 parent d47e795 commit 4505717

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

README.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ npm install niddle
2121

2222
```js
2323
const { parse } = require('niddle');
24+
const root = parse('<div id="foo" class="bar">hello <span>world</span></div>');
2425

25-
const html = '<div id="main"><span>Hello</span></div>';
26-
const root = parse(html);
27-
28-
const mainDiv = root.select('#main');
29-
mainDiv.append('<p>World</p>');
30-
31-
console.log(mainDiv.outerHtml()); // <div id="main"><span>Hello</span><p>World</p></div>
26+
const div = root.select('div');
27+
console.log(div.getAttribute('id')); // "foo"
28+
console.log(div.text()); // "hello world"
29+
div.setAttribute('title', 'my-title');
30+
console.log(div.outerHtml()); // <div id="foo" class="bar" title="my-title">hello <span>world</span></div>
3231
```
3332

3433
## API Documentation
@@ -100,18 +99,6 @@ Represents a DOM node and provides various manipulation methods.
10099
- **text(): string**
101100
- Gets the text content of the node.
102101

103-
#### Example
104-
105-
```js
106-
const { parse } = require('niddle');
107-
const root = parse('<div id="foo" class="bar">hello <span>world</span></div>');
108-
109-
const div = root.select('div');
110-
console.log(div.getAttribute('id')); // "foo"
111-
console.log(div.text()); // "hello world"
112-
div.setAttribute('title', 'my-title');
113-
console.log(div.outerHtml()); // <div id="foo" class="bar" title="my-title">hello <span>world</span></div>
114-
```
115102

116103
## Contributing
117104

0 commit comments

Comments
 (0)