admin管理员组文章数量:1357399
Hi would like to call a function if the answer to return confirm is yes, just don't know where to put the myFunction(). my code is below.
<a href="#" onClick="return confirm('Are you sure your want to delete?')">Delete</a>
Hi would like to call a function if the answer to return confirm is yes, just don't know where to put the myFunction(). my code is below.
<a href="#" onClick="return confirm('Are you sure your want to delete?')">Delete</a>
Share
Improve this question
asked Apr 28, 2017 at 5:35
KaoriYuiKaoriYui
9221 gold badge16 silver badges44 bronze badges
6 Answers
Reset to default 2Try it like,
<a href="#"
onClick="if(confirm('Are you sure your want to delete?')){alert('Delete');} else {alert('Dont delete')}">
Delete</a>
Snippet,
<a href="#"
onClick="if(confirm('Are you sure your want to delete?')){alert('Delete');} else {alert('Dont delete')}">
Delete</a>
try to wire the method call with &&
<a href="#" onClick="confirm('Are you sure your want to delete?') && myFunction() ">Delete</a>
Use like this .Don't use the confirmation inline of the onlclick
- Declare the
myfunction
in onclick - Then apply the confirmation inside the function
function myfunction(){
if(confirm('Are you sure your want to delete?')){
//do stuff
console.log('yes')
}
}
<a href="#" onClick="myfunction()">Delete</a>
onClick="return confirm('Are you sure your want to delete?') && Yourfunction() "
Use it like this
<a href="#" onClick="confirmDelete()">Delete</a>
<script type="text/javascript">
function confirmDelete()
{
if(confirm('Are you sure your want to delete?'))
{
/* Perform operations */
}
}
</script>
Use this
$(document).ready(function(){
$("#myID").on("click",function(){
if(confirm){
alert('enter your code here');
}
});
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" id="myID">Delete</a>
本文标签: javascriptReturn Confirm Call function if yesStack Overflow
版权声明:本文标题:javascript - Return Confirm Call function if yes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744033916a2579415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论