0

As the title says. The code that is used is not replacing all instances of the company's name. The website is using foundation and if I paste the script in the different section's it works.

Here is the code:

$(function () {
    $("body").children().each(function () {
        $(this).html($(this).html().replace("Oblique Creation Inc.", "Obl<span style='color:red;'>i</span>que Creation Inc."));
    });
});

Thanks for any help in advance.

palaѕн
  • 72,112
  • 17
  • 116
  • 136
James Kent
  • 23
  • 5
  • possible duplicate of http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript – Stumblor Sep 18 '15 at 15:26

1 Answers1

0

The Javascript replace function, when using a string as the first parameter, only replaces the first occurrence of that string.

Instead, use a regular expression:

$(this).html().replace(/Oblique Creation Inc/g, "Obl<span style='color:red;'>i</span>que Creation Inc");
Stumblor
  • 1,118
  • 8
  • 16