This repository was archived by the owner on Dec 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-19
lines changed
Expand file tree Collapse file tree 1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -21,14 +21,13 @@ npm install niddle
2121
2222``` js
2323const { 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
You can’t perform that action at this time.
0 commit comments