d
Amit DhamuSoftware Engineer
 

Escape HTML

1 minute read 00000 views
function escapeHtml(str) {
  var div = document.createElement('div')
  div.appendChild(document.createTextNode(str))

  return div.innerHTML
}