@constance-hua your logic seems too complex ... Instead please try this
hide your original button create a new button that open your confirmation modal if accepted, generate a click to the real hidden button. Eg: $("#myHiddenButton").trigger('click')done 🙂