0

I have a string 2 × 10 which is render with dangerouslySetInnerHTML inside a div; when user click that div i want to get the text 2 × 10, but with event.target.innerHTML i get 2 x 10 ("2 × 10" render as 2 x 10), there's a way to get the original dangerouslySetInnerHTML?

eneski
  • 1,377
  • 13
  • 35

2 Answers2

1

try using outerHTML: event.target.outerHTML

0

HTML encode it again with a function like this:

function htmlEntities(str) {
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

credit to j08691 for his answer here.