JSFiddle - React, Tailwind, and code Playground

by Michel Plungjan

HTML

<span>
 <b>hi_1</b>
 <b>hi_2</b>
 <b>hi_3</b>
 <b>hi_4</b>
<span>

JavaScript

// either
var x = $("span b").map(function() { 
  return $(this).text(); 
}).toArray().join(", "); 

// or
var y = $.trim($('span').text()) // Trim newlines near <span> and </span> tags
 .replace(/[\r\n]/g, ',');

alert(x+'\n'+y);