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?
Asked
Active
Viewed 40 times
0
eneski
- 1,377
- 13
- 35
Víctor Donat
- 49
- 6
-
`elm.textContent` will work, if anything will. – dandavis Aug 05 '21 at 21:50
-
2how it is related with reactjs? – eneski Aug 05 '21 at 21:51
2 Answers
0
HTML encode it again with a function like this:
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
credit to j08691 for his answer here.
AntiNeutronicPlasma
- 41
- 5