Jump to content

Replace string in div (Store page)

Recommended Posts

Hey. 

I'm currently trying to work out how I can customise some text elements inside a store page. The default HTML code is: 

<div class="product-price">
	from <span class="sqs-money-native">216.00</span> every month
</div>

Now my thinking was to replace "every" with "per" via Store Settings > Advanced > Page Header Code Injection

My desired result should look like:

<div class="product-price">
	from <span class="sqs-money-native">216.00</span> per month
</div>

I was trying to inject the following JavaScript code without any result: 

<script>
  let str = document.getElementsByClassName("product-price").innerHTML; 
  let res = str.replace("every", "per");
  document.getElementsByClassName("product-price").innerHTML = res;
</script>

Any helping thought is much appreciated :) 

Link to comment
  • Replies 1
  • Views 323
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.