'Make JS string replace work twice in WooCommerce

I'm using JS to string replace parts of text appended to the price.

add_filter( 'woocommerce_get_price_html', 'add_txt_to_price' );

function add_txt_to_price($price){
   global $product; 
//add text after price
    $text_to_add_after_price  = ' <span id="replace"> + VAT </span>'; //
    return  $price .   $text_to_add_after_price;
        }  

My JS

    function uge() {
    var str = document.getElementById("replace").innerHTML; 
    var res = str.replace(/VAT/gi, "Moms"); 
    document.getElementById("uge").innerHTML = res;
}

I'm adding the price a second time

add_action( 'woocommerce_after_add_to_cart_quantity', 'woocommerce_template_single_price', 31 );

and there fore the same div id is twice on the page

the string replace works fine on the price on top of the page but not the 2.

How can I make the string replace work twice for one div id?

I'm working from

https://stackoverflow.com/a/56033677



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source