JSFiddle - React, Tailwind, and code Playground
HTML
<dl>
<dt>A</dt>
<dd>A1</dd>
<dt>B</dt>
<dd>B1</dd>
<dd>B2</dd>
</dl>
<div id="output"></div>
CSS
#output {
padding : 20px;
background : grey;
}
JavaScript
var output = [],
temp = [];
$('dl').children().each(function () {
if (this.tagName == 'DT') {
if (0 in temp) {
output.push(temp);
}
temp = [$(this).text()];
} else {
temp.push($(this).text());
}
});
output.push(temp);
console.log(output);
$('#output').text(output.toSource());