Answer the question
In order to leave comments, you need to log in
Cheerio how to get html between two elements?
How to get html between two elements?
You need to get everything from the first h2 to the second, including text, tags, nested tags, but not including the h2 itself and its content.
<h2><b>Version 0.3.0</b></h2>
April 15, 2020
<span>What’s new</span>
<h2><b>Version 0.2.9</b></h2>
const content = $('h2')
.first()
.nextUntil('h2');
console.log($.html(content));
<span>What’s new</span>
April 15, 2020
<span>What’s new</span>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question