I've got a HTML link
<a href="http://jquery.com">Click</a>
I want to show a dialog box to ask if the user want to go to that website, if user clicked no, then does nothing, just close the dialog box; if clicked yes, then go to that link.
If you are okay with native alert boxes, then you can use confirm:
$(function() {
$("a .confirm").click(function(e) {
return confirm("Are you sure?");
});
});
HTML:
<a href="http://jquery.com" class="confirm" />
This will add this functionality to all links with the confirm class. :-)
This is just off the top of my head and not actually checked for accuracy but it's a close approximation of what you'll want to do.
$("a").click(function() {
return (confirm("Are you sure you want to do this?"));
});