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;
});
});
$(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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With