Home > Enterprise >  how can i set confirmation value for jQuery popup
how can i set confirmation value for jQuery popup

Time:12-30

my html

<a href="/cart/?empty_cart=yes" title="Empty Bag">Empty cart</a>

i tried to add popup confirmation for .emptybutton in jQuery but ( ok or cancel ) have the same value , if i click cancel it won't abort

enter image description here

this is the jQuery i used

$(document).ready(function() {
   $('.emptybutton').click(function() {
   if (confirm('Are you sure?')) {
      var url = $(this).attr('href');
      $('#content').load(url);
    }
  });
});

i dont know were is my problem

thanks for any help

CodePudding user response:

Please try to do like this. You should prevent the a button click when you click cancel button

$(document).ready(function() {
   $('.emptybutton').click(function(e) {
   if (confirm('Are you sure?')) {
      var url = $(this).attr('href');
      $('#content').load(url);
    } else {
      e.preventDefault();
    }
  });
});
  • Related