How to confirm clicking on a link using jQuery

后端 未结 5 1738
攒了一身酷
攒了一身酷 2021-02-13 15:23

I have many links in a HTML-table, which delete corresponding row, when clicked (calling a PHP-script via GET parameter).

They all have a class delete_row

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 15:58

    you can use preventDefault method of the event object in the handler function:

    jQuery('.delete_row').click(function(event){
         if(!confirm('Really Delete?')){
             event.preventDefault();
         }
    })
    

提交回复
热议问题