jQuery "after" add div twice

Viewed 44

I have problem where I want to add new div after specific div and this div is added twice:

<?php

add_action('wp_footer', 'myFunction');

function myFunction()
{

?>
    <script>
        jQuery(document).ready(function($) {

            var someVar = $(".product-total .woocommerce-Price-amount").html();
            $(
            ".order_item .woocommerce-Price-amount, .is-well .woocommerce-Price-amount "
            ).after(
            '<div class="price-wrapper eur"><div class="price">' +
                someVar +
                "</div></div>"
            ); 

        })

   
    </script>

 <?php

 }

Result is:

markup

jQuery is loaded once. This "after" is outside of loop. Even is only this jQuery line is in file is allways same result. With append is same situation.

this is happening on wordpress/woocommerce

Thanks for help,

A

2 Answers

Problem was that I calling footer in template 2 times (wp_footer and get_footer) and because of that jQuery triggered twice.

Related