Optimize
2.3K members online now
2.3K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me
star_border
Reply

Replace part of a text with Google Optimize

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm looking for a way to replace the € sign with nothing when the class of the element is money.

 

Here's what I have so far:

A selector .money

Change:

Script: Run JavaScript

function(element){

 element.innerText.replace('€','');

}

 

Which should work, but doesn't change anything on the page. What am I doing wrong?

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Tim C
May

Replace part of a text with Google Optimize

Google Employee
# 2
Google Employee

Hi

 

It should work, I think you just have a minor mistake in the code. Try this:

element.innerText = element.innerText.replace('€','');

 

Chances are that it probably doesn't matter but you may want to read this too

https://kellegous.com/j/2013/02/27/innertext-vs-textcontent/

Replace part of a text with Google Optimize

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

That works perfectly. Thank you!