JSFiddle - React, Tailwind, and code Playground

HTML

<span class="sp">CLICK</span><br />

JavaScript

$('.sp').click(function() {
$('body').append(escapeHtml('рас <br /> два'));
});

function escapeHtml(text) {
  var map = {
    '&': '&amp;',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#039;'
  };

  return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}