如何使用onclick确认和调用函数 [英] How to confirm and call function with onclick
本文介绍了如何使用onclick确认和调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在HTML onclick事件中使用return confirm();
调用JavaScript函数,还是需要执行包含确认并调用另一个函数的函数?
Can I call JavaScript function with return confirm();
in HTML onclick event or do I need to do function which contains confirmation and call to another function?
<button onclick="return confirm('Are you sure?'); saveandsubmit(event);"></button>
提前谢谢.
推荐答案
根据条件添加
<button onclick="if(confirm('Are you sure?')) saveandsubmit(event);"></button>
或
<button onclick="return confirm('Are you sure?')?saveandsubmit(event):'';"></button>
这篇关于如何使用onclick确认和调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文