Jump to content

Page Navigation - Replace Text with Image

Go to solution Solved by Lesum,

Recommended Posts

  • Replies 2
  • Views 222
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution
Posted

@ohhhgary Hi! You can add this code under Website > Pages > Website Tools > Code Injection > Header. You've to replace the image URL in the code as well.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>

<script>
  $(document).ready(function () {
    const $secondNavAnchor = $('.main-nav ul li:nth-child(2) a');

    // Add image url here
    const imageUrl = "https://images.squarespace-cdn.com/content/v1/5db7ce0cbe792566a205ef14/1572460848759-GPQTEQ966PD9GQ5V2ZV0/Screen%2BShot%2B2019-10-30%2Bat%2B11.39.56%2BAM.jpg?format=750w";

    $secondNavAnchor.empty().append(`<img src="${imageUrl}" alt="Navigation Image">`);
 });
</script>

<style>
  .main-nav ul li:nth-child(2) a img {
    width: 100px;
    height: auto;
  }
</style>

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

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.