/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
STANDARD ======== $('.ask-plain').click(function(e) { e.preventDefault(); thisHref = $(this).attr('href'); if(confirm('Are you sure')) { window.location = thisHref; } }); FANCY ====== $('.ask').click(function(e) { e.preventDefault(); thisHref = $(this).attr('href'); if($(this).next('div.question').length <= 0) $(this).after('<div class="question">Are you sure?<br/> <span class="yes">Yes</span><span class="cancel">Cancel</span></div>'); $('.question').animate({opacity: 1}, 300); $('.yes').live('click', function(){ window.location = thisHref; }); $('.cancel').live('click', function(){ $(this).parents('div.question').fadeOut(300, function() { $(this).remove(); }); });
URL: http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/
Comments
