A jQuery interaction widget enables visitors to your page to use a mouse (or trackpad or touchscreen) to control, modify, or in some other way play with a web page element. Here's a quick look at the available effects offered by jQuery UI:
blind
: Hides or shows an element as though the element was a window blind that you pull up or down. As an option, you can set thedirection
property toup
,down
,left
,right
,vertical
, orhorizontal
.
$('#my-div').toggle('blind',{direction: 'left'});
bounce
: Bounces an element up and down. As options, you can use thedistance
property to set the maximum bounce height (in pixels), and thetimes
property to set the number of bounces.
$('#my-div').effect('bounce', { distance: 200, times: 10 }, 1500 );
clip
: Hides or shows an element by shrinking the element vertically from the top and bottom. Set thedirection
property tohorizontal
to clip the element horizontally.
$('#my-div').toggle('clip');
drop
: Hides or shows an element by fading the element out or in while simultaneously sliding the element left or right. As an option, you can set thedirection
property toup
,down
,left
, orright
.
$('#my-div').toggle('drop',{direction: 'up'});
explode
: Hides an element by exploding it into pieces that fly off in all directions; shows an element by restoring the exploded pieces to their original configuration. You can set thepieces
property to the number of pieces to explode; the value should be a square, such as16
or25
(the default is9
).
$('#my-div').toggle('explode',{pieces: 16});
fade
: Hides or shows an element by fading the element out or in.
$('#my-div').toggle('fade', 'slow');
fold
: Hides an element by first shrinking it vertically to a 15-pixel height (the first “fold”), and then shrinking it horizontally until it disappears (the second “fold”); shows an element by reversing the folding procedure. For options, you can use thesize
property to set the height, in pixels, after the first fold (the default is15
); you can set thehorizFirst
property totrue
to make the first fold horizontal rather than vertical.
$('#my-div').toggle('fold',{size: 50});
highlight
: Highlights the background of an element. Use thecolor
property to specify the highlight color as an RGB triplet (the default is#ffff99
).
$('#my-div').effect('highlight',{color: 'ffd700'});
puff
: Hides or shows an element by scaling the element larger or smaller while simultaneously fading the element out or in. Add the percent property to set the maximum scale percentage (the default is150
).
$('#my-div').toggle('puff',{percent: 200});
pulsate
: Pulsates an element by quickly oscillating its opacity between0
and1
. Use thetimes
property to set the number of oscillations (the default is5
).
$('#my-div').effect('pulsate',{times: 10});
scale
: Grows or shrinks an element. For options, you can set thedirection
property tohorizontal
,vertical
, orboth
(the default); you can use theorigin
property to set the vanishing point as an array of the form['<em>h</em>','<em>v</em>']
, whereh
istop
,middle
, orbottom
, andv
isleft
,center
, orright
(the default is['middle','center']
); you can use thepercent
property to set thescale
factor; and you can set the scale property tobox
,content
, orboth
(the default).
$('#my-div').effect('scale',{percent: 25, origin: ['top','left']});
shake
: Shakes an element horizontally or vertically. As options, you can set thedirection
property to either left (the default) or right for a horizontal shake, or toup
ordown
for a vertical shake; you can use thedistance
property to set the shake displacement, in pixels (the default is20
); and you can set thetimes
property to set the number of shakes (the default is3
).
$('#my-div').effect('shake', { distance: 10, times: 10 }, 1000 );
size
: Changes the dimensions of an element to a specified width and height. You set the new dimensions by adding theto
property as an option and setting it to an object literal that specifies thewidth
andheight
, in pixels. You can also use theorigin
property to set the resize fixed point as an array of the form['<em>h</em>','<em>v</em>']
, whereh
istop
,middle
, orbottom
, andv
isleft
,center
, orright
(the default is['top','left']
); and you can set thescale
property tobox
,content
, orboth
(the default).
$('#my-div').effect('size',{to: {width: 200, height: 100}});
slide
: Hides or shows an element by sliding it out of or into the viewport. For options, you can use thedirection
property to set the direction of the slide toleft
(the default),right
,up
, ordown
; you can use thedistance
property to set the length of the slide, in pixels (the default is the width of the element ifdirection
isleft
orright
, or the height of the element ifdirection
isup
ordown
).