Javascript confirm dialog

后端 未结 5 874
野性不改
野性不改 2021-02-05 15:59

I want to add a confirm dialog to a delete button to ask the user whether it is ok or not deleting the selected item.

If not, nothing should happend, else a url should be

5条回答
  •  渐次进展
    2021-02-05 16:44

    You can use this: Download a bootboxjs from:[1]: http://bootboxjs.com/

    Create the Button (HTML)

    
    

    Call the Dialog:

      var myBtn = document.getElementById('btn');
    
    
      myBtn.addEventListener('click', function(event) {
          bootbox.confirm({
              size: "small",
              message: "Are you sure?",
              callback: function (result) {
                  /* result is a boolean; true = OK, false = Cancel*/
                  if (result == true) {
                      alert("ok pressed");
                  }
                  else {
                      alert("cancel pressed");
                  }
              }
          })
      });
    

提交回复
热议问题