Easy Tutorial
❮ Example Switchclass Example Sortable ❯

jQuery UI API - Shake Effect

Category

Effects

Usage

Description: Shakes the element multiple times along the vertical or horizontal direction.

Parameter Type Description Default Value
direction String Values "left" or "right" will shake the element horizontally, while "up" or "down" will shake it vertically. This value specifies the direction of the first step along the axis. "left"
distance Number The distance to shake. 20
times Integer The number of times to shake. 3

Example

Shakes a div.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Shake Effect Demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <style>
  #toggle {
    width: 100px;
    height: 100px;
    background: #ccc;
  }
  </style>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>

<p>Click anywhere to shake.</p>
<div id="toggle"></div>

<script>
$( document ).click(function() {
  $( "#toggle" ).effect( "shake" );
});
</script>

</body>
</html>

View Demo

❮ Example Switchclass Example Sortable ❯