// Ripple-effect animation (function($) { $(".ripple-effect").click(function(e){ var rippler = $(this); // create .ink element if it doesn't exist if(rippler.find(".ink").length == 0) { rippler.append(""); } var ink = rippler.find(".ink"); // prevent quick double clicks ink.removeClass("animate"); // set .ink diametr if(!ink.height() && !ink.width()) { var d = Math.max(rippler.outerWidth(), rippler.outerHeight()); ink.css({height: d, width: d}); } // get click coordinates var x = e.pageX - rippler.offset().left - ink.width()/2; var y = e.pageY - rippler.offset().top - ink.height()/2; // set .ink position and add class .animate ink.css({ top: y+'px', left:x+'px' }).addClass("animate"); }) })(jQuery);