正如标题所说。使用的代码不会替换公司名称的所有实例。该网站正在使用基础,如果我将脚本粘贴到不同的部分,则可以使用。
以下是代码:
$(function () {
$("body").children().each(function () {
$(this).html($(this).html().replace("Oblique Creation Inc.", "Obl<span style='color:red;'>i</span>que Creation Inc."));
});
});
感谢您提前提供任何帮助。
答案 0 :(得分:0)
当使用字符串作为该字符串的第一个参数only replaces the first occurrence时,Javascript替换函数。
相反,请使用正则表达式:
$(this).html().replace(/Oblique Creation Inc/g, "Obl<span style='color:red;'>i</span>que Creation Inc");