Skip to content

Commit

Permalink
Remove references to deprecated APIs from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored and fb55 committed Jan 30, 2019
1 parent b75bd02 commit bfd84be
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Readme.md
Expand Up @@ -233,21 +233,26 @@ $('[xml\\:id="main"');
```

### Rendering
When you're ready to render the document, you can use the `html` utility function:
When you're ready to render the document, you can call the `html` method on the "root" selection:

```js
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
$.root().html()
//=> <html>
// <head></head>
// <body>
// <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
// </body>
// </html>
```

If you want to return the outerHTML you can use `$.html(selector)`:
If you want to render the [`outerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) of a selection, you can use the `html` utility functon:

```js
$.html('.pear')
cheerio.html($('.pear'))
//=> <li class="pear">Pear</li>
```

Expand All @@ -268,15 +273,7 @@ You may also render the text content of a Cheerio object using the `text` static

```js
const $ = cheerio.load('This is <em>content</em>.')
$.text()
//=> This is content.
```

The method may be called on the Cheerio module itself--be sure to pass a collection of nodes!

```js
const $ = cheerio.load('<div>This is <em>content</em>.</div>')
cheerio.text($('div'))
cheerio.text($('body'))
//=> This is content.
```

Expand Down

0 comments on commit bfd84be

Please sign in to comment.