Return to Snippet

Revision: 27889
at June 26, 2010 01:34 by koko


Initial Code
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();
		});
});

Initial URL
http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/

Initial Description

                                

Initial Title
JQuery confirmation (+ fancy)

Initial Tags
jquery

Initial Language
jQuery