Reputation: 1873
I have an HTML element that looks like the following:
<span>‏3</span>
I set up a click event handler on this element (code not shown) that gets the innerHTML
of this span:
e.currentTarget.innerHTML
"3"
e.currentTarget.innerHTML.length
2
e.currentTarget.innerHTML.charAt(0)
""
e.currentTarget.innerHTML.charAt(1)
"3"
Based on the length, it seems that Javascript/Chrome is converting the ‏
marker to the unicode invisible character when is displayed on the console.
When the span contains no ‏
marker, things work as expected:
e.currentTarget.innerHTML
"3"
e.currentTarget.innerHTML.length
1
Any idea on how to strip this character? I've tried .trim()
and .replace()
.
Upvotes: 2
Views: 3616
Reputation: 1873
e.currentTarget.innerHTML.replace(/\u200f/g, '')
Seems to do the trick.
Upvotes: 3