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.
So something like:
if(SomeCondition) {
// disable click on button
var isOk = window.confirm("Are you sure?");
if(isOk) {
$("#button1").click();
}
}
Note: button1 has already been wired up with a click event via javascript from an external .js file that I can't change.
I don't know what the click event was bound too, so I have to disable the click if SomeCondition is true, then ask for confirmation, then continue with the click.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…