Return to Snippet

Revision: 16473
at August 5, 2009 16:05 by DrewDouglass


Initial Code
(function($){
		
		//Define the plugin, named 'linkNudge' 
		$.fn.linkNudge = function(params){
			
			//set default parameters 
			params = $.extend({
				padding: 20, 
				elapseTime: 300, 
				returnPadding: 0}, params);
			
			//Traverse every node passed 
			this.each(function(){
				
				//Define this as a single object 
				var $t = $(this);
				
				//Proceed to nudge on hover 
				$t.hover(function(){
					$t.stop().css('cursor', 'pointer').animate({paddingLeft: params.padding}, params.elapseTime);	
				}, function(){
					$t.stop().animate({paddingLeft: params.returnPadding}, params.elapseTime);
				});
				
			});
			
			return this;//Allow for chaining.
		};
	
	})(jQuery);

Initial URL
http://dev-tips.com/featured/link-nudge-jquery-plugin

Initial Description
Plugin Source.

Initial Title
jQuery Link Nudge Plugin

Initial Tags
javascript, jquery

Initial Language
JavaScript