In Cheerio, how do you get just the text of the current node only?
var cheerio = require('cheerio')
const htmlString = '<div>hello<span>world</span></div>'
$ = cheerio.load(htmlString, { ignoreWhitespace: true })
console.log($('div').text()) //helloworld
console.log($('span').text()) //world
How do you get just hello
?
You can do this:
console.log($('div').contents().first().text()) # hello