Encode HTML using JavaScript
To encode HTML:
const encodeHtml = html => {
const d = document.createElement('div');
d.textContent = html;
return d.innerHTML;
}
To encode HTML:
const encodeHtml = html => {
const d = document.createElement('div');
d.textContent = html;
return d.innerHTML;
}