jQuery Pulse / infinite background color fade in fade out


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

Requires jQuery Color plugin


Copy this code and paste it in your HTML
  1. (function($) {
  2. $.fn.pulse = function(options) {
  3.  
  4. options = $.extend({
  5. fadeFrom: "#87ff9b",
  6. fadeTo: "#FFFFFF"
  7. }, options);
  8.  
  9.  
  10. return this.each(function() {
  11.  
  12. var current = $(this);
  13. setInterval(function () {
  14. $(current).animate({'backgroundColor' : options.fadeFrom},1000)
  15. .animate({'backgroundColor' : options.fadeTo},1000)
  16. }, 1);
  17.  
  18. });
  19.  
  20. }
  21.  
  22. })(jQuery);
  23.  
  24. $(document).ready(function(){
  25.  
  26. $(this).pulse({"fadeFrom":"#87ff9b"});
  27.  
  28. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.