How Can I Change Text Content Of default_pagination PREV and NEXT Buttons

Solved
dannyelo
Excursionist
18 1 1

Hello,

I'm trying to change the text content of the default_pagination Previous and Next buttons with javascript, but I can't even target the elements.

First I tried this:

 

  const prevBtn = document.querySelector('#pagination .prev a');
  const nextBtn = document.querySelector('#pagination .next a');
  prevBtn.textContent = '<';
  nextBtn.textContent = '>';

 

And also this:

 

window.addEventListener('DOMContentLoaded', () => {
  const prevBtn = document.querySelector('#pagination .prev a');
  const nextBtn = document.querySelector('#pagination .next a');
  prevBtn.textContent = '<';
  nextBtn.textContent = '>';
});

 

 The content isn't changing and if I type prevBtn or nextBtn in the chrome dev console I got this error:

Uncaught ReferenceError: prevBtn is not defined
at <anonymous>:1:1

If I querySelect the elements in the chrome dev console, it works.

Thanks,

0 Likes
MS-WEB-DESIGNER
Shopify Partner
2877 180 493

This is an accepted solution.

Dear @dannyelo 

Add this question at "Shopify design" section for better solution

Click Here to Hire Shopify Store Customization Experts
Boost Conversions & Average Order Value with this
Best App for Sticky Add To Cart
0 Likes
dannyelo
Excursionist
18 1 1

Hey!

Yes that’s what I did already.

Thanks for reply.

 

0 Likes