最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Create new element in cheerio - Stack Overflow

programmeradmin2浏览0评论

What is the best way to create a new element in cheerio?

May be:

cheerio.load('<li>something in here!</li>')

or

$('li', '<li>bla, bla, bla, ...</li>')

What is the best way to create a new element in cheerio?

May be:

cheerio.load('<li>something in here!</li>')

or

$('li', '<li>bla, bla, bla, ...</li>')
Share Improve this question asked Apr 2, 2017 at 12:18 Clite TailorClite Tailor 4645 silver badges16 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Neither load nor the context string actually create HTML. They serve as a starting point for creating a virtual DOM.

Refer to the Manipulation section in the documentation for methods of injecting into the DOM. Namely, the following methods are provided for injection:

  • append
  • appendTo
  • prepend
  • prependTo
  • after
  • insertAfter
  • before
  • insertBefore
  • replaceWith
  • html
  • wrap
发布评论

评论列表(0)

  1. 暂无评论