Copyright © toggle Effects Utility

previous next



The Effect.toggle allows to toggle you between hide and show, slide up and slide down, and blind up and blind down.

For example, this checks if element is in hide state then it will show that element.

This utility function is most useful in scripts where the current state of the element is unknown or moot, and toggling the element to the opposite state is all that matters.


You can syntax form to use this effect:

Effect.toggle( element, [effectType], [options] );

Where effectType is one of the strings:

If the effectType is omitted, the default is appear

Effect Specific Parameters:

This effect does not have any other parameter except common parameters.


<title> examples</title>

   <script type="text/javascript" 
   <script type="text/javascript" 
   <script type="text/javascript">

   function AppearEffect(element){
       new Effect.toggle(element, 'Appear', {duration:3});
   function BUDEffect(element){
       new Effect.toggle(element,'Blind', {duration:3});
   function SUDEffect(element){
       new Effect.toggle(element,'Slide', {duration:3});


<div onclick="AppearEffect('myimage')">
    Click me to hide and show the image
<br />

<div onclick="BUDEffect('myimage')">
    Click me to Blind Up and Blind Down the image
<br />

<div onclick="SUDEffect('myimage')">
    Click me to Slide Up and Slide Down the image
<br />

<div id="myimage" onclick="AppearEffect(this);">
    <img src="/images/scriptaculous.gif" alt="" />


To understand it in better way you can Try it yourself.

previous next

Copyright ©