Keith Power Keith Power - 9 months ago 41
Javascript Question

javascript .replace a html tag does not replace

I am trying to replace some html but the replace is not taking place. I am using the javascript

and from what I can see I am using it right.

content.replace('<link rel="stylesheet" href="style.css">', '<style>html{background-color: blue;}<\/style>');


The strings replace() method returns a new string with the new value. It doesn't modify the original string.

Here is a simple example:

var str = "Hello World!";
var res = str.replace("World", "Foo");

console.log(str);  // prints Hello World!