Jump to content

Having trouble adding JavaScript code to code block successfully

Recommended Posts

I hired a coder to code a word carousel for me via JavaScript (see below).

//javascript code

var words = ["Be seen", "Celebrate", "Be bolder", "Connect", "Pursue", "Be uniquely You", "Think Limitless", "Expand Deeply", "Fly Further", "Lead with Love", "Dream again", "Impact"];
      var currentWord = 0;
      var slideInterval = setInterval(nextSlide, 500);
      function nextSlide() {
        document.querySelector("#slide").innerHTML = words[currentWord];
        currentWord = (currentWord + 1) % words.length;

I've copy and pasted the code into the code block. 

  • I've chosen HTML, disabled Display Source code, saved, and opened an incognito window it only shows the code.
  • I've chosen the JavaScript option and saved and I still have the same issue.

I'm sure there's an easy fix.  Any help would be appreciated.


Link to comment
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

3 minutes ago, Shermain said:

I've copy and pasted the code into the code block.

JavaScript code should be inserted between <script> and </script> tags in HTML.

Edited by paul2009

About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™. 
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!
If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.
Improve your online store with our extensions.

Link to comment

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.