Skip to content
Advertisement

Javascript: using the replace method on hex or dec character using the hex or dec value itself

I have a HTML table with a sorting function to sort in ascending or descending order by column. To show that I am using the down- and up- pointing small triangles with hex code x25BE; and x25B4; respectively.

The problem is that I cannot replace these hex characters using the replace method. I can only do that by using the character as follows: mystring.replace(‘▴’,”); but this is not possible because my javascript code is generated and that ▴ character cannot be used in the generating code.

It would be ok for me to use the decimal codes #9662; and #9652; , if that helps. See the code for my sortTable function for the expressions I tried, including the suggestions from this post: javascript replaceing special characters

JavaScript

Advertisement

Answer

As @Kelvin Sherlock wrote in a comment, using u25BE works: .replace(‘ u25BE;’,”);

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement