Latest web development tutorials

jQuery UI API - Vibration effects (Shake Effect)

category

Special effects (Effects)

usage

Description: vertical or horizontal direction repeatedly shock element.

shake

参数 类型 描述 默认值
direction String "left" 或 "right" 的值将水平震动元素,"up" 或 "down" 的值将垂直震动元素。该值指定元素沿轴线移动时第一步的方向。 "left"
distance Number 要震动的距离。 20
times Integer 要震动的次数。 3

Examples

Shake a div.

<! Doctype html>
<Html lang = "en">
<Head>
  <Meta charset = "utf-8">
  <Title> Vibration effects (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 on the vibration. </ P>
<Div id = "toggle"> </ div>
 
<Script>
$ (Document) .click (function () {
  $ ( "#toggle") .effect ( "Shake");
});
</ Script>
 
</ Body>
</ Html>