Trying to a add target=”_blank” to all tags using javascript in a string.
Why does this work:
var editdescription = itemdescription.replace(new RegExp("All","g"),"Every");
But not this?
var editdescription = itemdescription.replace(new RegExp("<a","g"),"<a target="_blank"");
You’ve nested your double quotes incorrectly. Instead of
try escaping the double quotes:
The way you wrote it was treated as two separate strings,
"<a target="and""with_blankin between.And as stated so many times before, preferably don’t parse HTML with regex.