I have to attach a jQuery to an invoice. Sometimes I have to print multiple invoices as once in a batch. When this happens my exact same jQuery appears for every invoice and
Change your repeating template to include a check:
Now it should run only once.
Another thing to try, where we remove the classes as we go...