I have a piece of html code:
<div><span>span_text</span>div_text</div>
I want to change the "div_text" using jQuery, having tried using $ .text ('changed_div_text'), but it didn’t work, it turned out that this is not what I want.
let tmpl = '<div><span>span_text</span>div_text</div>'
let $ = cheerio(tmpl)
console.log($.text())
$.text('changed_div_text')
console.log($.text())
As you can see, the text () function will also change the inner text, hope someone knows a way to solve this problem, thanks!
source
share