简体   繁体   中英

Create new element in cheerio

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>')

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM