script.aculo.us - 渐隐效果


说明

它使一个元素淡出,并通过将 CSS 显示属性设置为无来在效果结束时将其从文档流中移出。与Effect.Disappear 相反。

语法

你可以使用以下两种形式之一来使用此效果 −

new Effect.Fade('id_of_element', [options]);
OR
new Effect.Fade(element, [options]);

Effect 特定参数

此效果除了 通用参数 外,没有任何其他参数。

示例

<html>
   <head>
      <title>script.aculo.us examples</title>
		
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      <script type = "text/javascript" src = "/javascript/scriptaculous.js?load = effects" ></script>
		
      <script type = "text/javascript">
         function FadeEffect(element){
            new Effect.Fade(element, { duration:1});
         }
			
         function ShowEffect(element){
            new Effect.Appear(element, {duration:1, from:1.0, to:1.0});
         }
      </script>
   </head>

   <body>
      <div onclick = "FadeEffect('hideshow')">
         Click me to fade out the image
      </div>
      <br />
		
      <div onclick = "ShowEffect('hideshow')">
         Click me to display the image once again
      </div>
      <br />
		
      <div id = "hideshow">
         <img src = "/images/scriptaculous.gif" alt = "script.aculo.us" />
      </div>
   </body>
</html>

将产生以下结果 −

scriptaculous_effects.htm
广告