AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Optimize
5.3K members online now
5.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
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Tim C
May 2017

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/

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Tim C
May 2017

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!