Intercept click event on a button, ask for confirmation, then proceed

后端 未结 4 941
陌清茗
陌清茗 2020-12-08 10:33

Based on a variable SomeCondition, I need to intercept a click event on a button, and ask for confirmation, if they say ok, proceed, otherwise ignore click.

4条回答
  •  感情败类
    2020-12-08 11:22

    With jQuery to prevent default you just return false:

    $("#button1").click(function () {
        //do your thing
        return false;
    });
    

提交回复
热议问题