Reputation: 349
<span class="X">(‭−‭500‬‬</span>
I get the innerHTML from this span: var abc = document.querySelector("SELECTOR").innerHTML
It shows as "(-500" but when I copy it to the notepad it comes with the a invisible Unicode, how can I get the innerHTML just as simple text "-500" but without the Unicode and without the "(".
Upvotes: 1
Views: 2157
Reputation: 340055
You have to explicitly remove the invisible Unicode characters and convert some Unicode characters into their ASCII equivalents:
let x = document.querySelector('.x').innerHTML;
x = x.replace(/\u202d/g, ''); // (0x202d = 8237 "LEFT-TO-RIGHT OVERRIDE")
x = x.replace(/\u2212/g, '-'); // (0x2212 = 8277 "MINUS SIGN")
Upvotes: 3