JSFiddle - React, Tailwind, and code Playground

HTML

<!-- top -->
<div>top stuff</div>
<!-- Content -->
<div>content stuff</div>

JavaScript

$.fn.getComments = function () {
    return this.contents().map(function () {
        if (this.nodeType === 8) return this.nodeValue;
    }).get();
}

var comments = $('body').getComments();
alert(comments[0]); //returns "top"
alert(comments[1]); //Content"top"