如果返回确认的答案是肯定的,你想调用一个函数,只是不知道把myFunction放在哪里()。我的代码如下。
<a href="#" onClick="return confirm('Are you sure your want to delete?')">Delete</a>
答案 0 :(得分:2)
尝试使用&&
<a href="#" onClick="confirm('Are you sure your want to delete?') && myFunction() ">Delete</a>
答案 1 :(得分:1)
像这样使用。不要使用onlclick的内联确认
public static void main(String[] Args) throws IOException
{
......
}
myfunction
&#13;
function myfunction(){
if(confirm('Are you sure your want to delete?')){
//do stuff
console.log('yes')
}
}
&#13;
答案 2 :(得分:1)
试试吧,
<a href="#" onClick="myfunction()">Delete</a>
代码段,
<a href="#"
onClick="if(confirm('Are you sure your want to delete?')){alert('Delete');} else {alert('Dont delete')}">
Delete</a>
&#13;
答案 3 :(得分:0)
像这样使用
<a href="#" onClick="confirmDelete()">Delete</a>
<script type="text/javascript">
function confirmDelete()
{
if(confirm('Are you sure your want to delete?'))
{
/* Perform operations */
}
}
</script>
答案 4 :(得分:0)
使用此
$(document).ready(function(){
$("#myID").on("click",function(){
if(confirm){
alert('enter your code here');
}
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" id="myID">Delete</a>
&#13;
答案 5 :(得分:0)
onClick="return confirm('Are you sure your want to delete?') && Yourfunction() "