Change outerHTML in javascript

.replace creates a new transformed string; it does not alter the original variable. You're simply creating a new string and not storing the new string back into outerHTML, like:

$(editor[i])[0].outerHTML = $(editor[i])[0].outerHTML.replace('data-mce-style="color: red;"', '');

However, this only solves your immediate problem -- there are vastly better ways to accomplish what you need than stringifying and re-parsing your <p> element. Since you're using jQuery, the most obvious way would be to use the removeAttr method:

$(editor[i]).removeAttr('data-mce-style')​;​

Try:

$(editor[i]).removeAttr('data-mce-style')

http://api.jquery.com/removeAttr/

Of course this will apply to all elements in your selector. If you just want to apply this to element 0 then use:

$(editor[i]).first().removeAttr('data-mce-style')