jQuery: button click confirmation

jquery

Solution

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

Then remove onclick attribute from the HTML element.

Problem

I have the following html and jquery codes for deleting a member account with confirmation. But the code doesn't seem to work: even if I click "cancel" in the pop-up window, the request is still submitted and the account is deleted. How should I correct this? Thanks. HTML: ``` <button class="member" href="/admin?arg1=deleteMember" onclick="return confirm('Are you sure?')">Delete member</button> ``` jQuery: ``` $(document).ready(function() { $('.member').click(function() { var url = $(this).attr('href'); $('#content').load(url); return false; }); }); ```

Original source