jquery a method that makes a specified element flash

  • 2020-05-16 06:24:27
  • OfStack

This example shows how jquery makes a specified element flash. Share with you for your reference. The details are as follows:

The jQuery code is simple enough to make the specified elements change colors, flash, and call.


jQuery.fn.flash = function( color, duration )
{
  var current = this.css( 'color' );
  this.animate( { color: 'rgb(' + color + ')' }, duration / 2 );
  this.animate( { color: current }, duration / 2 );
}
// //www.ofstack.com Then use the above function as:
$( '#importantElement' ).flash( '255,0,0', 1000 );

I hope this article is helpful for you to design jQuery program.


Related articles: