I'm using jQuery to add a button next to all A>SPAN tags found on a page. The page itself grows as the user scrolls down, which is why I'm using the Scroll function - I need to continually add the button to the new page sections.
The below code continually adds buttons to the sections that already have buttons on them. I'm trying to only show one button next to each found tag combination. I've tried every combination I can think of. I'm hoping someone has an easy solution I can try.
Thank you.
$(window).scroll(function () {
if (!$("a span button").length) {
$("a span").after(
' <button type="button" class="btn btn-secondary btn-sm">BUTTON</button>'
);
}
});