0

my text contains ' and " characters so i want replace instead of ' as 1 and " as 2 using jquery

EX:

<span style="color: #ff0000; font-style: italic; text-decoration: underline line-through">text</span>

instead of special characters i want to put 1,2,3,4,etc.... the result will be

<span style=1color: #ff0000; font-style: italic; text-decoration: underline line-through1>text</span>
HamZa
  • 14,671
  • 11
  • 54
  • 75
vimal kumar
  • 27
  • 1
  • 9

1 Answers1

0

Here:

var rep = ['\'', '"', '!', '@', '#'];

for (var i = 0; i < rep.length; i++)
{
    str = str.replace(rep[i], ""+(i+1));
}

Notice how the index of special characters in array rep is utilized while replacing.

Prasanth
  • 5,230
  • 2
  • 29
  • 61