How to change the string content of a button on an infinite scrolling page?

77 views Asked by At

I've been doing some A/B testing at work. I want to test different CTA language on a page that has infinite scrolling, where new content is loaded for users as they reach a particular scroll depth.

So far, I've used this script to target the initial buttons on the page, but as you scroll the new buttons are not affected.

Any ideas on what I can add so that users always see the new button CTA as they scroll?

document.querySelectorAll('.button').forEach(button => button.textContent = 'Fancy CTA text');
0

There are 0 answers