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:
appendappendToprependprependToafterinsertAfterbeforeinsertBeforereplaceWithhtmlwrapIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With