JavaScript confirm cancel button not stopping JavaScript

前端 未结 7 1536
天涯浪人
天涯浪人 2020-12-24 15:27

I have a delete button that is tied to some comments on a page i have. When you click the delete button i am trying to get a confirm dialog box to pop up asking if you are

7条回答
  •  清酒与你
    2020-12-24 16:03

    You should return false to prevent the default event. This should work:

    onclick="confirm('Are you sure that you want to delete this comment?'); commentDelete(1);return false;"
    

提交回复
热议问题