Delete confirm modal by using bootstrap in JQuery

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i will show you how to Delete confirm modal by using bootstrap in JQuery? We always need to ask confirmation for the remove items. Here I mean we always need to ask before deleting items. So if we need to ask confirm before to do something like delete, change status, change value etc as we require. If we want to do with the better layout then we have to choose bootstrap.js and if we already use thee bootstrap then it’s very better.

so, let’s see the bellow example and use it.

Example:

<html lang="en">
<head>
    <title>Delete confirm modal using bootstrap example</title>  
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
</head>
<body>


<button class="btn btn-danger remove">Delete</button>


<!-- bootbox code -->
<script src="https://raw.githubusercontent.com/makeusabrew/bootbox/gh-pages/bootbox.js"></script>  
<script>
    $(document).on("click", ".remove", function(e) {
        bootbox.confirm("Are you sure you want to delete?", function(result) {
            if(result){
              console.log('write code of remove item.');
            }
        }); 
    });
</script>


</body>
</html>

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →