JSFiddle - React, Tailwind, and code Playground

by steveukx

HTML

<dl>
    <dt>blah</dt>
    <dd id="all"><span>foo</span>          <span>bar</span></dd>
</dl>

JavaScript

if(!String.prototype.trim) {
    String.prototype.trim = function() {
        return this.replace(/^\s*/, '').replace(/\s*$/, '');
    }
}

alert('"' + $('#all').text().trim().replace(/\s+/g, ' ') + '"');