(function($) { function numWith2D(num,d=2) { let str_saving = String(num); const index_dot = str_saving.indexOf("."); if(index_dot == -1){ return str_saving+".00"; } let split = str_saving.split("."); split[1] = split[1].length > d? split[1].substr(0,d):split[1]; return split[0]+"."+split[1]; } $("[data-testid=Checkout-button]").text("Checkout") $(".appstle_input_wrapper").each(function(){ const real = $(this).find('.appstle_sellingPlan_formattedCompareAtPrice') const selling = $(this).find('.appstle_sellingPlan_price.appstle_price_block'); const saving = real.text().replace("$","") - selling.text().replace("$",""); if (saving > 0){ $plan_label = $(this).find('.appstle-selling-plan-name-wrapper'); $plan_label.append(`Your Save $${numWith2D(saving)}`) $(this).find('.appstle_sellingPlan_discountText') .appendTo($plan_label); } console.log(numWith2D(saving)); }) })(jQuery)