jQuery Link Nudge Plugin


/ Published in: JavaScript
Save to your folder(s)

Plugin Source.


Copy this code and paste it in your HTML
  1. (function($){
  2.  
  3. //Define the plugin, named 'linkNudge'
  4. $.fn.linkNudge = function(params){
  5.  
  6. //set default parameters
  7. params = $.extend({
  8. padding: 20,
  9. elapseTime: 300,
  10. returnPadding: 0}, params);
  11.  
  12. //Traverse every node passed
  13. this.each(function(){
  14.  
  15. //Define this as a single object
  16. var $t = $(this);
  17.  
  18. //Proceed to nudge on hover
  19. $t.hover(function(){
  20. $t.stop().css('cursor', 'pointer').animate({paddingLeft: params.padding}, params.elapseTime);
  21. }, function(){
  22. $t.stop().animate({paddingLeft: params.returnPadding}, params.elapseTime);
  23. });
  24.  
  25. });
  26.  
  27. return this;//Allow for chaining.
  28. };
  29.  
  30. })(jQuery);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.