How to stop button onclick event using javascript?

Is there anyone that can assist?

 <div class="select-button">
     <button type="button" class="button-1 select-billing-address-button" onclick="selectBillingAddress@(item.Id)()">@T("Checkout.BillToThisAddress")</button>
     
     <script asp-location="Footer">
         function selectBillingAddress@(item.Id)() {
             if ($('#@Html.IdFor(model => model.ShipToSameAddress)')
                 .is(':checked')) {
                 setLocation(
                     '@Html.Raw(Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id, shipToSameAddress = "true"}))');
             } else {
                 setLocation(
                     '@Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id})');
             }
         }
     </script>
 </div>

I would like to check a few conditions before making a call, but I am unable to modify the function or button at this time. Could you please provide a solution? I would like to use load new js.
Many thanks in advance.

I’m trying to add some code under the function and override the old one, but nothing is working. I want to use load new js to accomplish this, and I can only do that.