jQuery UI Shake Effect

The jQuery UI shake effect moves an element repeatedly in a horizontal or vertical direction.

This is a jQuery UI effect, so the page using it must load jQuery UI in addition to jQuery.

Syntax and Main Options Top ↑

The general form is $(selector).effect(effectName, options, duration, complete). The options available depend on the selected effect.

  • times: Number of shakes. The default is 3.
  • distance: Movement distance in pixels. The default is 20.
  • direction: Choose "left", "right", "up" or "down".
  • duration: Animation duration.
  • complete: Function called after completion.

Examples Top ↑

Basic syntax

$( "#element" ).effect( "shake", { times: 4, distance: 40, direction: "left" }, 600, function () {
    // Runs after the effect finishes.
});

Default shake effect

$( "#d1" ).effect( "shake" );

Run from a button

$( "#b1" ).on( "click", function () {
    $( "#d1" ).effect( "shake" );
});

Change the number of shakes

$( "#d1" ).effect( "shake", { times: 4 } );

Change the distance

$( "#d1" ).effect( "shake", { distance: 200 } );

Combine options with a callback

$( "#b1" ).on( "click", function () {
    $( "#d1" ).effect( "shake", { times: 10, distance: 200 }, 5000, function () {
        alert( "The shake effect has finished." );
    });
});

Open the Shake Effect demo →

View demo of all jQuery UI effects →

When to Use This Effect Top ↑

Use this effect when the animation itself helps explain a state change or draws attention to an element. For routine interfaces, keep motion short and purposeful so it does not distract from the content.

← Previous effect · Next effect →

Back to jQuery Effects · jQuery Tutorials Home






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer