-3

I would need to find and replace some text on my website (online store) using CS. Specifically, I need to find ,90 in price area and replace this with upper index <sup>90</sup>. At the moment the price is displayed as follows:

39,90 Kč, 

i want to be displayed:

39<sup>90</sup> Kč 

I tried it according to the instructions

document.body.innerHTML.replace

unfortunately without success.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79

1 Answers1

0

You could use a simple regular expression first to find all of the occurrences of ,90 in the string:

/,90/g

And then you could use String.prototype.replace() to replace it with the <sup></sup> tags:

str.replace(/,90/g, "<sup>90</sup>");

Demonstration:

var str = "30,90 12,90 3,90";
str = str.replace(/,90/g, "<sup>90</sup>");
document.body.innerHTML = str;
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79